From 69453746a15033f680a1d3bc6facc058cd0d942b Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sat, 13 Jul 2024 05:31:45 -0700 Subject: [PATCH] Add property for configuring the maximum number of patterns to process in order to support backtests spanning multiple years / decades --- indicators/ThreeCandleReversal.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indicators/ThreeCandleReversal.cs b/indicators/ThreeCandleReversal.cs index d667e4e..34c6e7c 100644 --- a/indicators/ThreeCandleReversal.cs +++ b/indicators/ThreeCandleReversal.cs @@ -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; } } }