So I've been playing around with an opening range break method that looks at the first 30 min of SPY.
I've manually checked the orders that it's generated, and for the most part it looks correct but I have a few issues. I'm wondering if anyone can help me out here please?
- Why was there no order entered on the 28th of Apr? The 30 min opening range was broken in the morning around 10:25 am. If functioning correctly, it should've entered a trade at 10:25am and then stopped me out for a loss.
- Why did my trailing stops not update on 4th May? It should've done update fields until around 11:35am but on this day the trailing stops did not update and I took a full stop loss shortly after 1:00 pm on the backtest.
- Same question for 5th May - for some reason my stops didn't update until 12:01pm. The SPY was trending down pretty hard in the morning so it should've trailed it down as it made lower lows.
- 6th May - I'm unsure why there was no order entered. The 30min opening range was broken. If functioning correctly I would've entered long and then gotten stopped out.
- 9th May - I'm confused on the trailing stop updates here. It continues updating until 11:40 am, even though the 1 minute candles were not making lower lows.
Any help greatly appreciated - thanks!
Vladimir
Ivanc,
The attached algorithm is very similar to the one I have already posted on your request  and left unanswered by you.
It doesn't have the problems you face in your algorithm.
Â
Why was there no order entered on the 28th of Apr?
Â
2022-04-28T14:02:00Z          SPY        418.96    -238        Market    Filled      -99712.48               Â
2022-04-28T15:20:00Z          SPY        421.25    238         Market    Filled      100257.5 Stop LossÂ
Â
Why did my trailing stops not update on 4th May?Â
Â
2022-04-29T14:19:00Z          SPY        422.58    -234        Market    Filled      -98883.72               Â
2022-04-29T16:42:00Z          SPY        418.29    234         Market    Filled      97879.86 Take ProfitÂ
Â
Same question for 5th May - for some reason my stops didn't update until 12:01pm.Â
The SPY was trending down pretty hard in the morning so it should've trailed itÂ
down as it made lower lows.
Â
2022-05-05T14:03:00Z          SPY        420.62    -236        Market    Filled      -99266.32
2022-05-05T14:42:00Z          SPY        416.25    236         Market    Filled      98235     Take Profit              Â
2022-05-05T14:42:00Z          SPY        416.24    -241        Market    Filled      -100313.84
2022-05-05T16:01:00Z          SPY        411.53    241         Market    Filled      99178.73 Take ProfitÂ
Â
6th May - I'm unsure why there was no order entered. The 30min opening range was broken.Â
If functioning correctly I would've entered long and then gotten stopped out.
Â
2022-05-06T14:48:00Z          SPY        411.82    246         Market    Filled      101307.72              Â
2022-05-06T15:59:00Z          SPY        409.56    -246        Market    Filled      -100751.76             Stop LossÂ
Â
9th May - I'm confused on the trailing stop updates here. It continues updatingÂ
until 11:40 am, even though the 1 minute candles were not making lower lows.
Â
2022-05-09T14:10:00Z          SPY        402.96    -250        Market    Filled      -100740  Â
2022-05-09T19:33:00Z          SPY        398.71    250         Market    Filled      99677.5  Take Profit
Â
If you are satisfied with my answer, please accept it and don't forget to like it
Mcdawgzy
Hi Vladimir - I'm not looking to change my algorithm, just trying to understand why it's not behaving as intended. Your version of the algorithm uses a fixed SL and TP. I use no TP and a trailing stop to get out of positions - it doesn't explain any of the issues or questions I've raised.
Mcdawgzy
Ok, so this is some strange behavior. I ran only for the 28/04 date and you can see in the below attached backtest that there are trades entered for this date.
When I try to backtest using a wider range (which includes the 28/04 date), no trades happen on 28/04 even though the below backtest shows that it should…
I'm a bit lost on why this would happen - any ideas from anyone?
Louis Szeto
Hi Ivanc
The minute bar EndTime is at :00 of the previous minute (i.e. EndTime 01:00 is the data from 00:00-00:59), so the MAX and MIN indicator will also account for the 16:00:00 bar in the previous day. To solve so, you may set the scheduled event at 10:01 rather than 10:00.
For the 28-4-2022-only algorithm, the MIN indicator is only constructed by the previous 29 minute-bars, so the trade is submitted.
Best
Louis
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.
Mcdawgzy
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!