Skip to content

Commit

Permalink
Resolved review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueNina committed Dec 17, 2024
1 parent 2848fa4 commit 1e9f82e
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions Indicators/ZigZag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ namespace QuantConnect.Indicators
public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider
{
/// <summary>
/// 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.
/// </summary>
public decimal HighPivot { get; set; }
private IBaseDataBar _lastPivot;

/// <summary>
/// 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.
/// </summary>
public decimal LowPivot { get; set; }
private readonly int _minTrendLength;

/// <summary>
/// The sensitivity threshold for detecting significant price movements.
Expand All @@ -44,12 +44,6 @@ public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider
/// </summary>
private readonly decimal _sensitivity;

/// <summary>
/// The minimum number of bars required to confirm a valid trend.
/// Ensures that minor fluctuations in price do not create false pivots.
/// </summary>
private readonly int _minTrendLength;

/// <summary>
/// A counter to track the number of bars since the last pivot was identified.
/// Used to enforce the minimum trend length requirement.
Expand All @@ -63,10 +57,16 @@ public class ZigZag : BarIndicator, IIndicatorWarmUpPeriodProvider
private bool _lastPivotWasLow;

/// <summary>
/// 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.
/// </summary>
private IBaseDataBar _lastPivot;
public decimal HighPivot { get; private set; }

/// <summary>
/// Stores the most recent low pivot value in the ZigZag calculation.
/// Updated whenever a valid low pivot is identified.
/// </summary>
public decimal LowPivot { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="ZigZag"/> class with the specified parameters.
Expand Down Expand Up @@ -171,5 +171,16 @@ protected override decimal ComputeNextValue(IBaseDataBar input)
_count++;
return currentPivot;
}

/// <summary>
/// Resets this indicator to its initial state
/// </summary>
public override void Reset()
{
_lastPivot = null;
HighPivot = 0;
LowPivot = 0;
base.Reset();
}
}
}

0 comments on commit 1e9f82e

Please sign in to comment.