kestrel-chartkitv0.33.0

← All examples

macd

Moving Average Convergence Divergence

macd

examples/site_showcase.rs
// Moving Average Convergence Divergence
// Defaults of "macd" (see the indicator reference)
let params = HashMap::from([
    ("fast_len".to_string(), 12.0),
    ("signal_len".to_string(), 9.0),
    ("slow_len".to_string(), 26.0),
]);
let mut indicator = build_checked("macd", &params)?;

for bar in &bars {
    if let Some(output) = indicator.on_bar(bar) {
        // output.value, output.extra[...], indicator.alerts()
    }
}
Moving Average Convergence Divergence. Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 10 alerts in view, the latest as markers.Moving Average Convergence Divergence. Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 10 alerts in view, the latest as markers.
  • Oscillators
  • unit: Unitless