Add property for configuring the maximum number of patterns to process in order to support backtests spanning multiple years / decades

This commit is contained in:
moshferatu 2024-07-13 05:31:45 -07:00
parent 99c71f59f2
commit 69453746a1

View File

@ -45,6 +45,7 @@ namespace NinjaTrader.NinjaScript.Indicators
BarLookback = 5;
BullishLevelStroke = new Stroke(Brushes.LimeGreen, DashStyleHelper.Solid, 2);
BearishLevelStroke = new Stroke(Brushes.Red, DashStyleHelper.Solid, 2);
MaxPatterns = 0;
}
if (State == State.DataLoaded)
{
@ -133,6 +134,9 @@ namespace NinjaTrader.NinjaScript.Indicators
detectedPatterns.RemoveAt(i);
}
}
if (MaxPatterns > 0 && detectedPatterns.Count > MaxPatterns)
detectedPatterns.RemoveAt(0);
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
@ -177,6 +181,10 @@ namespace NinjaTrader.NinjaScript.Indicators
[XmlIgnore]
[Display(Name = "Bearish Level", Description = "Stroke for bearish level drawn on chart", Order = 3, GroupName = "3CR")]
public Stroke BearishLevelStroke { get; set; }
[Range(0, int.MaxValue)]
[Display(Name = "Max Patterns", Description = "Maximum number of patterns to process", Order = 4, GroupName = "3CR")]
public int MaxPatterns { get; set; }
}
}