I have a system that is like to backtest that uses alligator Williams lines. My issue is getting price in relation to the sma line that’s moved forward by 8 bars. I’ve done some googling but couldn’t really find an idea they fits.
Basically I want to know if price is above or below an sma line that’s been moved forward. Is this possible? I have a custom indicator coded in mt4 but I’m having a hell of a time reworking it.
Gurumeher Sawhney
Please correct me if I am wrong, but it seems like at time t you need to access the the SMA at time t-8 (since we need an sma line moved forward by 8 bars).
If this is the case we can calculate the SMA everyday and store the data in a Rolling Window. A rolling window, is an array of data that allows for reverse list access semantics. In order to access the correct SMA, we can access the 7th index, since the rolling window has 0-based indexing.
Note: In order to make sure the rolling windows are properly populated, we can warm-up the algorithm. There is also an SMA helper method, so that you will not need to keep calculating the values.
Karolis Krikstanas
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!