Hello,
In getting acclimated to QC and Lean I am trying to make sure that I am going about things efficently and as intended. In looking at the MovingAverageConvergenceDivergence indicator class, it looks like the consturctors set the indicator WarmUpPeriod = provided signal period as seen below.
public MovingAverageConvergenceDivergence(int fastPeriod, int slowPeriod, int signalPeriod, MovingAverageType type = MovingAverageType.Exponential)
: this($"MACD({fastPeriod},{slowPeriod},{signalPeriod})", fastPeriod, slowPeriod, signalPeriod, type)
{
}
public MovingAverageConvergenceDivergence(string name, int fastPeriod, int slowPeriod, int signalPeriod, MovingAverageType type = MovingAverageType.Exponential)
: base(name)
{
Fast = type.AsIndicator(name + "_Fast", fastPeriod);
Slow = type.AsIndicator(name + "_Slow", slowPeriod);
Signal = type.AsIndicator(name + "_Signal", signalPeriod);
Histogram = new Identity(name + "_Histogram");
WarmUpPeriod = signalPeriod;
}
In my experiance working with other quanitative strategies, I would expect this indicator to not be "Ready" untill enough data have been pumped into the indicator that is equal to the greatest value of 'fastPeriod', 'slowPeriod', and 'signalPeriod'. So I would expect that the WarmUpPeriod for the default MACD values (12, 26, 9) would be 26 and not 9 as it currently is. I would expect the constructor to set the WarmUpPeriod as something like this to get the largest of the values:
public MovingAverageConvergenceDivergence(string name, int fastPeriod, int slowPeriod, int signalPeriod, MovingAverageType type = MovingAverageType.Exponential)
: base(name)
{
Fast = type.AsIndicator(name + "_Fast", fastPeriod);
Slow = type.AsIndicator(name + "_Slow", slowPeriod);
Signal = type.AsIndicator(name + "_Signal", signalPeriod);
Histogram = new Identity(name + "_Histogram");
WarmUpPeriod = Math.Max(fastPeriod, Math.Max(slowPeriod, signalPeriod));
}
I know that I can set the algorithm warm up period manually, or manually handle indicator data, or I could create my own MACD indicator to handle this how I would expect. However, all of these seem cumbersome to do especcially when using custom data and data custom data consolidators for something so commonly used with indicators.
I guess my question is, is this the intended behavior for the MACD indicator? And if so is there a less cumbersome way to update the indicator warmup period with custom consolidated data?
Thank you,
Derek Melchin
Hi Leland,
The `Signal` of the MACD indicator is a moving average of the difference between `Fast` and `Slow`. Refer to the source code here. As a result, the `WarmUpPeriod` should be
max(fastPeriod, slowPeriod) + signalPeriod
Track our progress on updating this here.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Leland Procell
Thank you for correcting my error and opening the github issue for this!
Thank you
Leland Procell
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!