I am trying to code a simple 5 miute open range break strategy. The strategy takes only the long side of a trade if the opening 5 minute range is broken anytime before 12pm on the trading day. Positions are exited 15 minutes before the close. However, the first day of trading the algo seems to do what is expected but after that the 5 miute range isn't being observed by the algorithm for each day to have its on trading occur. Can someone help me to understand where I am going wrong in my code logic or implementation? Thank you
Ashutosh
Hi Akira
I was taking a look at the code and there was only one small logical error which was avoiding the trades to flow for the next days.
According to your code the “self.openingBar = None” only when there is a position taken on the start of the day and is closed 15 minutes before market close. But on 4th January there was no long position triggered which in return did not trigger the “self.openingBar=None”.
You can change this logic to change “self.openingBar=None” regardless of whether there happens to be a trade or not which will give you the correct trades.
Placing “
”
I have attached a backtest for reference. Let me know if this helps.
Best,
Ashutosh
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.
Akira
Firstly, thank you so much for the reply, I am really building faith in this QuantConnect Community. I will review the code you've shared with me in detail. Thank you again
Akira
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!