pub fn stochastic_oscillator(close: f64, high: f64, low: f64) -> Result<f64> {
	if high < low {
		return Err(AnalysisError::HighLessThanLow);
	}
	if close > high {
		return Err(AnalysisError::CloseGreaterThanHigh);
	}
	if close < low {
		return Err(AnalysisError::CloseLessThanLow);
	}
	Ok(match high == low {
		true => 50.,
		false => 100. * (close - low) / (high - low),
	})
}
/// Stochastic oscillator is a momentum indicator developed by Dr. George Lane
/// that shows the location of the value relative to the high-low range. The
/// output of the function oscillates between 0 and 100.
///
/// Typical number of periods for stochastic oscillator calculations is 5, 9,
/// or 14. Stochastic oscillator is used together with 1 or 2 signal lines.
/// The 1st signal line is the exponential moving averege of the stochastic
/// oscillator value and the 2nd signal line is the exponential moving average
/// of the 1st signal line value. Signal lines are typically calculated from
/// 3 previous periods.
///
/// `high` and `low` arguments are the highest high and the lowest low
/// respectively for the used period.
///
/// The formula is modified to return 50 if the highest high equals the
/// lowest low.
///
/// # Arguments
///
/// * `close` - closing price for the period
/// * `high` - highest price for the period
/// * `low` - lowest price for the period
///
/// # Example
///
/// ```
/// use stat::analysis::momentum;
///
/// let value = momentum::stochastic_oscillator(80., 90., 50.);
/// assert_eq!(value.ok(), Some(75.));
/// ```
Stochastic oscillator is a momentum indicator developed by Dr. George Lane
that shows the location of the value relative to the high-low range. The
output of the function oscillates between 0 and 100.

Typical number of periods for stochastic oscillator calculations is 5, 9,
or 14. Stochastic oscillator is used together with 1 or 2 signal lines.
The 1st signal line is the exponential moving averege of the stochastic
oscillator value and the 2nd signal line is the exponential moving average
of the 1st signal line value. Signal lines are typically calculated from
3 previous periods.

`high` and `low` arguments are the highest high and the lowest low
respectively for the used period.

The formula is modified to return 50 if the highest high equals the
lowest low.
Stochastic oscillator is a momentum indicator developed by Dr . George Lane that shows the location of the value relative to the high - low range . The output of the function oscillates between 0 and 100 . Typical number of periods for stochastic oscillator calculations is 5 9 or 14 . Stochastic oscillator is used together with 1 or 2 signal lines . The 1st signal line is the exponential moving averege of the stochastic oscillator value and the 2nd signal line is the exponential moving average of the 1st signal line value . Signal lines are typically calculated from 3 previous periods . ` high ` and ` low ` arguments are the highest high and the lowest low respectively for the used period . The formula is modified to return 50 if the highest high equals the lowest low .
pub fn stochastic_oscillator(close: f64, high: f64, low: f64) -> Result<f64> {
	if high < low {
		return Err(AnalysisError::HighLessThanLow);
	}
	if close > high {
		return Err(AnalysisError::CloseGreaterThanHigh);
	}
	if close < low {
		return Err(AnalysisError::CloseLessThanLow);
	}
	Ok(match high == low {
		true => 50.,
		false => 100. * (close - low) / (high - low),
	})
}
pub fn stochastic_oscillator ( close : f64 , high : f64 , low : f64 ) -> Result < f64 > { if high < low { return Err ( AnalysisError :: HighLessThanLow ) ; } if close > high { return Err ( AnalysisError :: CloseGreaterThanHigh ) ; } if close < low { return Err ( AnalysisError :: CloseLessThanLow ) ; } Ok ( match high == low { true => 50. , false => 100. * ( close - low ) / ( high - low ) , } ) }
Stochastic oscillator is a momentum indicator developed by Dr. George Lane
that shows the location of the value relative to the high-low range.
Stochastic oscillator is a momentum indicator developed by Dr . George Lane that shows the location of the value relative to the high - low range .
close
f64
high
f64
low
f64
example
```
use stat::analysis::momentum.


` ` ` use stat :: analysis :: momentum .