pub struct HeikinAshiBar {
pub timestamp: i64,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: f64,
pub source: Bar,
}Expand description
One Heikin-Ashi candle together with the observed bar it was derived from.
The OHLC values here are computed, not traded. volume is the source bar’s volume, passed
through unchanged — Heikin-Ashi averages prices, it does not redistribute turnover.
The link back to source is kept so that anything needing a real price (a fill, a stop
distance, a risk figure) can reach it without a second lookup, and so a renderer can draw the
transformed candle against the bar it belongs to.
Fields§
§timestamp: i64Timestamp of the source bar, unchanged: one input bar yields exactly one output candle.
open: f64(previous ha_open + previous ha_close) / 2; on the first bar of a series (open + close) / 2.
high: f64max(source high, ha_open, ha_close).
low: f64min(source low, ha_open, ha_close).
close: f64(open + high + low + close) / 4 of the source bar.
volume: f64The source bar’s volume, unchanged.
source: BarThe observed bar this candle was derived from.
Implementations§
Source§impl HeikinAshiBar
impl HeikinAshiBar
Sourcepub fn to_bar(&self) -> Bar
pub fn to_bar(&self) -> Bar
Converts to a plain Bar, for the deliberate case of running an indicator over the
transformed series.
This drops the distinction between computed and observed prices — the resulting bar looks
like any other. Pair it with HeikinAshiBar::synthetic_identity so the series it
belongs to still says where its prices came from, and keep fill, slippage and risk
arithmetic on HeikinAshiBar::source.
Sourcepub fn synthetic_identity(base: &SeriesIdentity) -> SeriesIdentity
pub fn synthetic_identity(base: &SeriesIdentity) -> SeriesIdentity
The identity a transformed series carries: base with its provenance set to
Provenance::Synthetic, since the prices are derived rather than observed.
Trait Implementations§
Source§impl Clone for HeikinAshiBar
impl Clone for HeikinAshiBar
Source§fn clone(&self) -> HeikinAshiBar
fn clone(&self) -> HeikinAshiBar
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more