[][src]Struct yata::methods::CrossAbove

pub struct CrossAbove { /* fields omitted */ }

Searches for value timeseries line crosses base line upwards

If value crossed base upwards, then returns Action::BUY_ALL

Else returns Action::None

Parameters

Has no parameters

Input type

Input type is (value: ValueType, base: ValueType)

Output type

Output type is Action

Examples

use yata::core::Method;
use yata::methods::CrossAbove;

let mut cross_above = CrossAbove::new((), (0.0, 5.0));

let t1 = vec![0.0, 1.0, 2.0, 3.0, 4.0, 5.0];
let t2 = vec![5.0, 3.0, 1.8, 2.9, 4.1, 5.6];
let r  = vec![ 0,   0,   1,   0,   0,   0 ];

(0..t1.len()).for_each(|i| {
	let value = t1[i];
	let base = t2[i];
	let cross_value = cross_above.next((value, base)).analog();
	assert_eq!(cross_value, r[i]);
});

Perfomance

O(1)

See also

Cross, CrossUnder

Implementations

impl CrossAbove[src]

pub fn binary(&mut self, value1: ValueType, value2: ValueType) -> bool[src]

Returns true when value1 crosses value2 timeseries upwards Otherwise returns false

Trait Implementations

impl Clone for CrossAbove[src]

impl Copy for CrossAbove[src]

impl Debug for CrossAbove[src]

impl Default for CrossAbove[src]

impl<'de> Deserialize<'de> for CrossAbove[src]

impl Method for CrossAbove[src]

type Params = ()

Method parameters

type Input = (ValueType, ValueType)

Input value type

type Output = Action

Output value type

impl Serialize for CrossAbove[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.