kestrel-chartkitv0.49.0

← All examples

schaff_trend_cycle

Schaff Trend Cycle: the MACD line of the close run twice through a stochastic of cycle bars, each smoothe…

schaff_trend_cycle

examples/site_showcase.rs
// Schaff Trend Cycle: the MACD line of the close run twice through a stochastic of `cycle` bars, each smoothed with `factor`; 0 to 100, published from bar max(slow, 2 * cycle - 1). A stage without range repeats its previous stochastic; at the start the first stage reads 50 and the second the smoothed value itself, so a flat series stays at 50, a steady fall reads 0 and a steady rise 100.
// Defaults of "schaff_trend_cycle" (see the indicator reference)
let params = HashMap::from([
    ("cycle".to_string(), 10.0),
    ("factor".to_string(), 0.5),
    ("fast".to_string(), 23.0),
    ("lower".to_string(), 25.0),
    ("slow".to_string(), 50.0),
    ("upper".to_string(), 75.0),
]);
let mut indicator = build_checked("schaff_trend_cycle", &params)?;

for bar in &bars {
    if let Some(output) = indicator.on_bar(bar) {
        // output.value, output.extra[...], indicator.alerts()
    }
}
Schaff Trend Cycle: the MACD line of the close run twice through a stochastic of `cycle` bars, each smoothed with `factor`; 0 to 100, published from bar max(slow, 2 * cycle - 1). 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.Schaff Trend Cycle: the MACD line of the close run twice through a stochastic of `cycle` bars, each smoothed with `factor`; 0 to 100, published from bar max(slow, 2 * cycle - 1). 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.
  • Oscillators
  • unit: Ratio