Add the ability to limit the number of pivots to process during backtesting

This commit is contained in:
moshferatu 2024-07-17 08:19:26 -07:00
parent acbf718aa8
commit 85ca05edd8

View File

@ -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; }
}
}