Skip to main content

HeikinAshiBar

Struct HeikinAshiBar 

Source
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: i64

Timestamp 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: f64

max(source high, ha_open, ha_close).

§low: f64

min(source low, ha_open, ha_close).

§close: f64

(open + high + low + close) / 4 of the source bar.

§volume: f64

The source bar’s volume, unchanged.

§source: Bar

The observed bar this candle was derived from.

Implementations§

Source§

impl HeikinAshiBar

Source

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.

Source

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

Source§

fn clone(&self) -> HeikinAshiBar

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HeikinAshiBar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for HeikinAshiBar

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for HeikinAshiBar

Source§

fn eq(&self, other: &HeikinAshiBar) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for HeikinAshiBar

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for HeikinAshiBar

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.