I have a 3-period SMA that I want to offset/displace forward by 3 bars, but I'm not sure how to do this using QC. In TOS, it is just an argument included in the SMA constructor.
I have a 3-period SMA that I want to offset/displace forward by 3 bars, but I'm not sure how to do this using QC. In TOS, it is just an argument included in the SMA constructor.
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.
Hi Cassidy,
In LEAN, we have data up until the Time Frontier, so having a 3-period SMA into the future is not possible. However, if you would like to displace the 3-period SMA into the past, we can do this combining the Delay indicator with the SMA. I’ve shown how to do this in the attached backtest.
Best,
Shile Wen
Hi Shile,
I'm not trying to project into the future, I'm trying to bring the past's 3-period moving average forward. For instance, let's say it is the 8th and I'm looking at the value of the 3-day MA on 8/5 and see that it is 200. I want the value to be displaced 3 bars forward so that the value of the 3-day MA on 8/8 is 200. I understand this would place data "into the future" (as it would move the MA value from the 8th to the 11th), but that data can be truncated for all intents & purposes.
Hi Kassidy,
The provided solution in my previous comment does exactly this.
Best,
Shile Wen
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!