diff --git a/indicators/PivotPoints.cs b/indicators/PivotPoints.cs index e0d7ac5..1e9aaec 100644 --- a/indicators/PivotPoints.cs +++ b/indicators/PivotPoints.cs @@ -3,6 +3,7 @@ using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using System; using System.Collections.Generic; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Windows.Media; @@ -46,6 +47,9 @@ namespace NinjaTrader.NinjaScript.Indicators RollingWindow = 10; PivotHighStroke = new Stroke(Brushes.LimeGreen, 3); PivotLowStroke = new Stroke(Brushes.Red, 3); + + // For use during backtesting in order to limit the number of pivots processed. + MaxPivots = 0; } if (State == State.DataLoaded) { @@ -108,6 +112,9 @@ namespace NinjaTrader.NinjaScript.Indicators pivots.Add(pivot); Pivot[0] = pivot; } + + if (MaxPivots > 0 && pivots.Count > MaxPivots) + pivots.RemoveAt(0); } protected override void OnRender(ChartControl chartControl, ChartScale chartScale) @@ -151,6 +158,9 @@ namespace NinjaTrader.NinjaScript.Indicators [Display(Name = "Pivot Low Stroke", Order = 3, GroupName = "Pivot")] public Stroke PivotLowStroke { get; set; } + + [Browsable(false)] + public int MaxPivots { get; set; } } }