Function macd

Source
pub fn macd(
    fast_period: u32,
    slow_period: u32,
    signal_period: u32,
    close: &Vec<f64>,
) -> (Vec<f64>, Vec<f64>, Vec<f64>, TA_Integer)
Expand description

TA_MACD - Moving Average Convergence/Divergence

Input = double Output = double, double, double

ยงOptional Parameters

optInFastPeriod:(From 2 to 100000) Number of period for the fast MA

optInSlowPeriod:(From 2 to 100000) Number of period for the slow MA

optInSignalPeriod:(From 1 to 100000) Smoothing for the signal line (nb of period)

#Sample

let close_prices: Vec<f64> = vec![
       1.087010, 1.087120, 1.087080, 1.087170, 1.087110, 1.087010, 1.087100, 1.087120, 1.087110,
       1.087080, 1.087000, 1.086630, 1.086630, 1.086610, 1.086630, 1.086640, 1.086650, 1.086650,
       1.086670, 1.086630,
];
let (macd,macd_signal,macd_hist, begin) = rust_ta_lib::wrapper::macd(2,5,10,&close_prices);
for (index, value) in macd.iter().enumerate() {
       println!("macd index {} = {}", begin + index as i32 + 1, value);
       println!("macd_signal index {} = {:?}", begin + index as i32 + 1, macd_signal.get(index));
       println!("macd_hist index {} = {:?}", begin + index as i32 + 1, macd_hist.get(index));
 }