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
4 changes: 3 additions & 1 deletion Indicators/McClellanOscillator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public class McClellanOscillator : TradeBarIndicator, IIndicatorWarmUpPeriodProv
/// <summary>
/// Required period, in data points, for the indicator to be ready and fully initialized.
/// </summary>
public int WarmUpPeriod => EMASlow.WarmUpPeriod + ADDifference.WarmUpPeriod;
/// <remarks>The two periods share a bar: EMASlow is fed by ADDifference and only
/// once it is ready, so ADDifference's last warm-up bar is EMASlow's first input.</remarks>
public int WarmUpPeriod => EMASlow.WarmUpPeriod + ADDifference.WarmUpPeriod - 1;

/// <summary>
/// Initializes a new instance of the <see cref="McClellanOscillator"/> class
Expand Down
3 changes: 2 additions & 1 deletion Tests/Indicators/McClellanOscillatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public override void WarmsUpProperly()
indicator.Update(new TradeBar() { Symbol = Symbols.AAPL, Close = i, Volume = 1, Time = reference.AddMinutes(i) });
indicator.Update(new TradeBar() { Symbol = Symbols.MSFT, Close = i, Volume = 1, Time = reference.AddMinutes(i) });
indicator.Update(new TradeBar() { Symbol = Symbols.GOOG, Close = i, Volume = 1, Time = reference.AddMinutes(i) });

Assert.AreEqual(i == indicator.WarmUpPeriod, indicator.IsReady);
}

Assert.AreEqual(0m, indicator.Current.Value);
Assert.AreEqual(indicator.WarmUpPeriod * 3, indicator.Samples);
Assert.IsTrue(indicator.IsReady);
}

[Test]
Expand Down
3 changes: 2 additions & 1 deletion Tests/Indicators/McClellanSummationIndexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ public override void WarmsUpProperly()
indicator.Update(new TradeBar() { Symbol = Symbols.AAPL, Close = i, Volume = 1, Time = reference.AddMinutes(i) });
indicator.Update(new TradeBar() { Symbol = Symbols.MSFT, Close = i, Volume = 1, Time = reference.AddMinutes(i) });
indicator.Update(new TradeBar() { Symbol = Symbols.GOOG, Close = i, Volume = 1, Time = reference.AddMinutes(i) });

Assert.AreEqual(i == indicator.WarmUpPeriod, indicator.IsReady);
}

Assert.AreEqual(60m, indicator.Current.Value);
Assert.AreEqual(indicator.WarmUpPeriod * 3, indicator.Samples);
Assert.IsTrue(indicator.IsReady);
}

[Test]
Expand Down