kestrel-chartkitv0.33.0

← All examples

oscillator_pivot_divergence

Divergence with the pivots found in the oscillator

oscillator_pivot_divergence

examples/site_showcase.rs
// Divergence with the pivots found in the oscillator (TradingView's divergence scripts: ta.pivotlow/pivothigh of the oscillator, compared with the last pivot only); price read at the same bars; same oscillators, alerts and extras as pivot_divergence
// Defaults of "oscillator_pivot_divergence" (see the indicator reference)
let params = HashMap::from([
    ("left".to_string(), 5.0),
    ("max_distance".to_string(), 60.0),
    ("max_prior_pivots".to_string(), 1.0),
    ("min_distance".to_string(), 5.0),
    ("oscillator".to_string(), 0.0),
    ("right".to_string(), 5.0),
]);
let mut indicator = build_checked("oscillator_pivot_divergence", &params)?;

for bar in &bars {
    if let Some(output) = indicator.on_bar(bar) {
        // output.value, output.extra[...], indicator.alerts()
    }
}
Divergence with the pivots found in the oscillator (TradingView's divergence scripts: ta.pivotlow/pivothigh of the oscillator, compared with the last pivot only); price read at the same bars; same oscillators, alerts and extras as pivot_divergence. Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 1 alerts in view, the latest as markers.Divergence with the pivots found in the oscillator (TradingView's divergence scripts: ta.pivotlow/pivothigh of the oscillator, compared with the last pivot only); price read at the same bars; same oscillators, alerts and extras as pivot_divergence. Default parameters on synthetic 4-hour bars of a fictitious CASOON share (invented prices), the last 150 bars; 1 alerts in view, the latest as markers.
  • Market structure and patterns
  • unit: Unitless