Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Indicators/CandlestickPatterns/AbandonedBaby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public override bool IsReady
get { return Samples > Period; }
}

/// <summary>
/// Required period, in data points, for the indicator to be ready and fully initialized.
/// </summary>
public override int WarmUpPeriod => Period + 1;

/// <summary>
/// Computes the next value of this indicator from the given state
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Indicators/CandlestickPatterns/MatHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public override bool IsReady
get { return Samples > Period; }
}

/// <summary>
/// Required period, in data points, for the indicator to be ready and fully initialized.
/// </summary>
public override int WarmUpPeriod => Period + 1;

/// <summary>
/// Computes the next value of this indicator from the given state
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Indicators/CandlestickPatterns/RiseFallThreeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public override bool IsReady
get { return Samples > Period; }
}

/// <summary>
/// Required period, in data points, for the indicator to be ready and fully initialized.
/// </summary>
public override int WarmUpPeriod => Period + 1;

/// <summary>
/// Computes the next value of this indicator from the given state
/// </summary>
Expand Down
18 changes: 18 additions & 0 deletions Tests/Indicators/CandlestickPatterns/CandlestickPatternTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ 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)
{
// 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);

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<IndicatorBase<IBaseDataBar>, double> Assertion
{
get
Expand Down