parent
7fd3d80504
commit
c3e1b50b5f
@ -1,2 +1,3 @@ |
|||||||
pub mod ma; |
pub mod ma; |
||||||
pub mod rsi; |
pub mod rsi; |
||||||
|
pub mod macd; |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
use crate::indicators::ma::exponential_moving_average; |
||||||
|
use crate::data::quotes::HOLC; |
||||||
|
use crate::data::TimeStamp; |
||||||
|
|
||||||
|
pub struct MACD { |
||||||
|
upperBand: Vec<f64>, |
||||||
|
lowerBand: Vec<f64>, |
||||||
|
signalLine: Vec<f64>, |
||||||
|
} |
||||||
|
impl MACD { |
||||||
|
pub fn new<C: HOLC + TimeStamp + Clone>(data: Vec<C>, upperBand: Option<usize>, lowerBand: Option<usize>, signalBand: Option<usize>) { |
||||||
|
// This is going to need a custom implementation. It's not efficent to clone and iterate through the data 3 seperate times
|
||||||
|
let ub = upperBand.unwrap_or(26); |
||||||
|
let lb = lowerBand.unwrap_or(12); |
||||||
|
let sb = signalBand.unwrap_or(9); |
||||||
|
|
||||||
|
let u_ema = exponential_moving_average(data.clone(), ub); |
||||||
|
let l_ema = exponential_moving_average(data.clone(), lb); |
||||||
|
let s_ema = exponential_moving_average(data.clone(), sb); |
||||||
|
|
||||||
|
println!("u_ema = {:?}", u_ema); |
||||||
|
println!("u_ema.len() = {:?}", u_ema.len()); |
||||||
|
|
||||||
|
println!("l_ema = {:?}", l_ema); |
||||||
|
println!("l_ema.len() = {:?}", l_ema.len()); |
||||||
|
|
||||||
|
println!("s_ema = {:?}", s_ema); |
||||||
|
println!("s_ema.len() = {:?}", s_ema.len()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
fn moving_average_convergence_divergence<C: HOLC>(data: Vec<C>) { |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue