pub struct BarInput {
pub close: Decimal,
pub high: Decimal,
pub low: Decimal,
pub open: Decimal,
pub volume: Decimal,
}Expand description
Thin input type for signal computation, decoupled from OhlcvBar.
Carrying all four price fields and volume allows future indicators (e.g. MACD on
high-low, OBV on volume) without forcing a dependency on OhlcvBar.
Fields§
§close: DecimalClosing price (used by most indicators).
high: DecimalHigh price of the bar.
low: DecimalLow price of the bar.
open: DecimalOpening price of the bar.
volume: DecimalTotal traded volume during the bar.
Implementations§
Source§impl BarInput
impl BarInput
Sourcepub fn new(
close: Decimal,
high: Decimal,
low: Decimal,
open: Decimal,
volume: Decimal,
) -> Self
pub fn new( close: Decimal, high: Decimal, low: Decimal, open: Decimal, volume: Decimal, ) -> Self
Constructs a BarInput with all fields explicitly specified.
Sourcepub fn from_close(close: Decimal) -> Self
pub fn from_close(close: Decimal) -> Self
Constructs a BarInput from a single close price, setting all OHLC fields to close
and volume to zero. Useful in tests and for close-only indicators (SMA/EMA/RSI).
Sourcepub fn typical_price(&self) -> Decimal
pub fn typical_price(&self) -> Decimal
Returns the typical price of this bar: (high + low + close) / 3.
Sourcepub fn weighted_close(&self) -> Decimal
pub fn weighted_close(&self) -> Decimal
Returns the weighted close price: (high + low + close + close) / 4.
Weights the close twice, giving it extra significance compared to the typical price. Used by some indicators (e.g. CCI variants) and charting systems as a price reference.