kestrel-chartkitv0.49.0

← All examples

ott

Optimized Trend Tracker: a trailing stop whose distance is a percent of the level on a variable average of …

ott

examples/site_showcase.rs
// Optimized Trend Tracker: a trailing stop whose distance is a percent of the level on a variable average of the close, shifted by half the percent to the side the average lies on (extras `var`, `stop`, `direction`). The average starts at the first close, the momentum sums use the bars available at the start and the direction starts undecided; the line is not shifted, and the alerts compare the average with the line two bars earlier.
// Defaults of "ott" (see the indicator reference)
let params = HashMap::from([
    ("cmo_len".to_string(), 9.0),
    ("length".to_string(), 2.0),
    ("percent".to_string(), 1.4),
]);
let mut indicator = build_checked("ott", &params)?;

for bar in &bars {
    if let Some(output) = indicator.on_bar(bar) {
        // output.value, output.extra[...], indicator.alerts()
    }
}
Optimized Trend Tracker: a trailing stop whose distance is a percent of the level on a variable average of the close, shifted by half the percent to the side the average lies on (extras `var`, `stop`, `direction`). Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 4 alerts in view, the latest as markers.Optimized Trend Tracker: a trailing stop whose distance is a percent of the level on a variable average of the close, shifted by half the percent to the side the average lies on (extras `var`, `stop`, `direction`). Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 4 alerts in view, the latest as markers.
  • Moving averages, bands and trend lines
  • unit: Price