kestrel-chartkitv0.41.0

← All examples

Market regime

Synthetic 4-hour candles of a fictitious CASOON share in four legs: up, sideways, down, sideways. classify_regime runs on every bar with ADX(14) and ATR(14); the band below the candles shows the regime, the lowest pane the ADX with the trend threshold of 20. The first bars have no regime yet: ADX and ATR are still warming up.

Market regime

examples/site_showcase.rs
let mut adx = build_checked("adx", &HashMap::new())?;
let mut atr = build_checked("atr", &HashMap::new())?;

for (i, bar) in bars.iter().enumerate() {
    let (Some(a), Some(t)) = (adx.on_bar(bar), atr.on_bar(bar)) else { continue };
    // The ATR indicator reports 100 * ATR / close; classify_regime expects the fraction.
    let regime = classify_regime(&bars[..=i], a.value, t.value / 100.0);
}
Market regime per bar · CASOON (fictitious) 4hSynthetic 4-hour candles of a fictitious CASOON share in four legs: up, sideways, down, sideways. classify_regime runs on every bar with ADX(14) and ATR(14); the band below the candles shows the regime, the lowest pane the ADX with the trend threshold of 20. The first bars have no regime yet: ADX and ATR are still warming up.Market regime per bar · CASOON (fictitious) 4h8090100110120130Price01Regime0204060801002026-01-052026-01-122026-01-192026-01-26ADXCASOON (fictitious) (hollow: rising, filled: falling)Bullish expansionBearish expansionTransitionADX 14trend threshold 20: 20trend threshold 20
  • classify_regime
  • adx
  • atr