kestrel-chartkitv0.49.0

← All examples

halftrend

HalfTrend: a trend line from the extremes and averages of the last amplitude bars, with an ATR envelope

halftrend

examples/site_showcase.rs
// HalfTrend: a trend line from the extremes and averages of the last `amplitude` bars, with an ATR envelope (extras `trend`, `atr_high`, `atr_low`). It starts undecided and watches both sides instead of starting up; the first line is seeded with the extreme that decided it. Published once decided from bar atr_len.
// Defaults of "halftrend" (see the indicator reference)
let params = HashMap::from([
    ("amplitude".to_string(), 2.0),
    ("atr_len".to_string(), 100.0),
    ("deviation".to_string(), 2.0),
]);
let mut indicator = build_checked("halftrend", &params)?;

for bar in &bars {
    if let Some(output) = indicator.on_bar(bar) {
        // output.value, output.extra[...], indicator.alerts()
    }
}
HalfTrend: a trend line from the extremes and averages of the last `amplitude` bars, with an ATR envelope (extras `trend`, `atr_high`, `atr_low`). 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.HalfTrend: a trend line from the extremes and averages of the last `amplitude` bars, with an ATR envelope (extras `trend`, `atr_high`, `atr_low`). 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