Back

MACD History / Rolling Window

Hello,

I was hoping someone may be able to assist me.  I have been playing with the MACD and Rolling Window examples and have been having a hard time getting a rolling window of MACD values (Current and Signal) to access later.

I've attached the working python code below, could someone please give me some direction on switching the SMA 5 day average to the MACD values?

Cheers

Update Backtest








Hey Rob,

I'm not familiar with Python Lean but i'll give it a shot!

A RollingWindow can store anything, you must give them the Generic (the type of object they will store).

You use:

self.MacdWin = RollingWindow[IndicatorDataPoint,](5)

The eqauivalent in C# is:

var rollinWindw = new RollingWindow<IndicatorDataPoint>(5);

There you’re saying: keep me the last 5 IndicatorDataPoint object I'll feed into you

But if you use:

var rollinWindw = new RollingWindow<List<decimal>>(5);

You are asking to keep the last five List of numbers.

Once the RollingWindow is defined like that you can keep the last 5 observations of a MACD imply by:

rollinWindw.Add(new List<decimal>
{
macd,
macd.Fast,
macd.Slow,
macd.Signal,
});

Hope it helps!

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed