diff --git a/Indicators/ZigZag.cs b/Indicators/ZigZag.cs index f98b05b26d81..71bd5b0d3069 100644 --- a/Indicators/ZigZag.cs +++ b/Indicators/ZigZag.cs @@ -26,16 +26,16 @@ namespace QuantConnect.Indicators public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider { /// - /// Stores the most recent high pivot value in the ZigZag calculation. - /// Updated whenever a valid high pivot is identified. + /// The most recent pivot point, represented as a bar of market data. + /// Used as a reference for calculating subsequent pivots. /// - public decimal HighPivot { get; set; } + private IBaseDataBar _lastPivot; /// - /// Stores the most recent low pivot value in the ZigZag calculation. - /// Updated whenever a valid low pivot is identified. + /// The minimum number of bars required to confirm a valid trend. + /// Ensures that minor fluctuations in price do not create false pivots. /// - public decimal LowPivot { get; set; } + private readonly int _minTrendLength; /// /// The sensitivity threshold for detecting significant price movements. @@ -44,12 +44,6 @@ public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider /// private readonly decimal _sensitivity; - /// - /// The minimum number of bars required to confirm a valid trend. - /// Ensures that minor fluctuations in price do not create false pivots. - /// - private readonly int _minTrendLength; - /// /// A counter to track the number of bars since the last pivot was identified. /// Used to enforce the minimum trend length requirement. @@ -63,10 +57,16 @@ public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider private bool _lastPivotWasLow; /// - /// The most recent pivot point, represented as a bar of market data. - /// Used as a reference for calculating subsequent pivots. + /// Stores the most recent high pivot value in the ZigZag calculation. + /// Updated whenever a valid high pivot is identified. /// - private IBaseDataBar _lastPivot; + public decimal HighPivot { get; private set; } + + /// + /// Stores the most recent low pivot value in the ZigZag calculation. + /// Updated whenever a valid low pivot is identified. + /// + public decimal LowPivot { get; private set; } /// /// Initializes a new instance of the class with the specified parameters. @@ -171,5 +171,16 @@ protected override decimal ComputeNextValue(IBaseDataBar input) _count++; return currentPivot; } + + /// + /// Resets this indicator to its initial state + /// + public override void Reset() + { + _lastPivot = null; + HighPivot = 0; + LowPivot = 0; + base.Reset(); + } } }