From 338e88fed71ee5441c1353a5d7806fe59549c9d5 Mon Sep 17 00:00:00 2001 From: mkzung <103102868+mkzung@users.noreply.github.com> Date: Sun, 16 Aug 2026 21:39:05 +0500 Subject: [PATCH 1/2] Report the extra bar three candlestick patterns wait for --- Indicators/CandlestickPatterns/AbandonedBaby.cs | 5 +++++ Indicators/CandlestickPatterns/MatHold.cs | 5 +++++ .../CandlestickPatterns/RiseFallThreeMethods.cs | 5 +++++ .../CandlestickPatternTests.cs | 15 +++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/Indicators/CandlestickPatterns/AbandonedBaby.cs b/Indicators/CandlestickPatterns/AbandonedBaby.cs index 0e0f95417dd0..c74aab3add03 100644 --- a/Indicators/CandlestickPatterns/AbandonedBaby.cs +++ b/Indicators/CandlestickPatterns/AbandonedBaby.cs @@ -90,6 +90,11 @@ public override bool IsReady get { return Samples > Period; } } + /// + /// Required period, in data points, for the indicator to be ready and fully initialized. + /// + public override int WarmUpPeriod => Period + 1; + /// /// Computes the next value of this indicator from the given state /// diff --git a/Indicators/CandlestickPatterns/MatHold.cs b/Indicators/CandlestickPatterns/MatHold.cs index 51d72c3646b0..1f38702f0952 100644 --- a/Indicators/CandlestickPatterns/MatHold.cs +++ b/Indicators/CandlestickPatterns/MatHold.cs @@ -85,6 +85,11 @@ public override bool IsReady get { return Samples > Period; } } + /// + /// Required period, in data points, for the indicator to be ready and fully initialized. + /// + public override int WarmUpPeriod => Period + 1; + /// /// Computes the next value of this indicator from the given state /// diff --git a/Indicators/CandlestickPatterns/RiseFallThreeMethods.cs b/Indicators/CandlestickPatterns/RiseFallThreeMethods.cs index 6327a7d5a5eb..ec3bb6b1c6be 100644 --- a/Indicators/CandlestickPatterns/RiseFallThreeMethods.cs +++ b/Indicators/CandlestickPatterns/RiseFallThreeMethods.cs @@ -67,6 +67,11 @@ public override bool IsReady get { return Samples > Period; } } + /// + /// Required period, in data points, for the indicator to be ready and fully initialized. + /// + public override int WarmUpPeriod => Period + 1; + /// /// Computes the next value of this indicator from the given state /// diff --git a/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs b/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs index 557564d71118..f8823b279c70 100644 --- a/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs +++ b/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs @@ -153,6 +153,21 @@ public void ResetsProperly(CandlestickPattern indicator, string columnName, stri TestHelper.TestIndicatorReset(indicator, testFileName); } + [Test, TestCaseSource(nameof(PatternTestParameters))] + public void WarmsUpProperly(CandlestickPattern indicator, string columnName, string testFileName) + { + var period = indicator.WarmUpPeriod; + var startDate = new DateTime(2019, 1, 1); + + for (var i = 0; i < period; i++) + { + indicator.Update(new TradeBar(startDate.AddDays(i), Symbols.SPY, 100m + i, 105m + i, 95m + i, 100m + i, 100m, Time.OneDay)); + Assert.AreEqual(i == period - 1, indicator.IsReady); + } + + Assert.AreEqual(period, indicator.Samples); + } + private static Action, double> Assertion { get From 7205d54164968855e47ff26c95049615b478738a Mon Sep 17 00:00:00 2001 From: mkzung <103102868+mkzung@users.noreply.github.com> Date: Sun, 16 Aug 2026 23:56:13 +0500 Subject: [PATCH 2/2] Start WarmsUpProperly from a reset indicator --- .../Indicators/CandlestickPatterns/CandlestickPatternTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs b/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs index f8823b279c70..4671dc07ce70 100644 --- a/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs +++ b/Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs @@ -156,6 +156,9 @@ public void ResetsProperly(CandlestickPattern indicator, string columnName, stri [Test, TestCaseSource(nameof(PatternTestParameters))] public void WarmsUpProperly(CandlestickPattern indicator, string columnName, string testFileName) { + // the sample count below only means anything from a known starting point + indicator.Reset(); + var period = indicator.WarmUpPeriod; var startDate = new DateTime(2019, 1, 1);