egui_charts/studies/builtin/
ma_ema_cross.rs1use super::ma_combination::impl_ma_preset;
2use super::{AverageLine, AverageType, MACombination};
3use crate::studies::palette;
4
5#[derive(Clone)]
7pub struct EMACross {
8 inner: MACombination,
9}
10
11impl EMACross {
12 pub fn new(fast_period: usize, slow_period: usize) -> Self {
14 let inner = MACombination::new(vec![
15 AverageLine::new(AverageType::Exponential, fast_period, palette::ORANGE),
16 AverageLine::new(AverageType::Exponential, slow_period, palette::DARK_GREEN),
17 ])
18 .unwrap();
19 Self { inner }
20 }
21}
22
23impl Default for EMACross {
24 fn default() -> Self {
25 Self::new(12, 26)
26 }
27}
28
29impl_ma_preset!(
30 EMACross,
31 "EMA Cross",
32 "EMA Cross - Two exponential averages with crossing markers",
33 palette::LIGHT_BLUE
34);