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", ¶ms)?;
for bar in &bars {
if let Some(output) = indicator.on_bar(bar) {
// output.value, output.extra[...], indicator.alerts()
}
}