use crate::trend_value::TrendValue;

#[derive(Debug, Clone, Default)]
pub struct EdgeValue {
    pub upper: f64,
    pub lower: f64,
    pub center: f64,
    pub width: f64,
    pub width_trend: TrendValue,
}

impl EdgeValue {
    pub fn new(upper: f64, lower: f64, center: f64, period: usize) -> Self {
        let width = upper - lower;
        let mut width_trend = TrendValue::new(period);
        width_trend.update_value(width);

        Self {
            upper,
            lower,
            center,
            width,
            width_trend,
        }
    }

    pub fn is_width_expanding(&self) -> bool {
        self.width > self.width_trend.current_ema()
    }
}
