Hello,
while developing a strategy I came upon a strange thing, a wrong opening of the trade. According to my strategy there could be a signal in previous bar but then the order was Next Bar At Market but the order opened at the LOW. That trade shows up in the report but shouldn't with that wrong transaction-open.
What I've seen is that doing a playback of the chart with the running strategy the ghost trade is not seen, it's seen after I finish the playback. Removing the strategy and adding it again without doing anything more doesn't help. The trade occurs.
Because that trade doesn't occur in playback there must be a difference between that ghost trade and the correct trade.
Checking now there are more trades like this starting at the low of the bar after on the previous bar my strategy has placed an order like this:
Buy("L P1 " + sId) orderSize Contracts Next Bar At Market
It's invalidating the backtest result. I'm questioning that strategy since many hours trying to figure out the problem why the strategy is doing so incredible good. Live tests are doing great also without much difference except the opening of some trades. So the two screenshots show the same candles and trades but on the first image the strategy was walking forward live and the second image has just the trades calculated as a backtest. The latter one has the opening at the low and not short below the high (which is right after checking on the minute chart).
Is there anything like this already documented and maybe a hint how I can correct that wrong behaviour?
Here some information regarding my setup:
Timeframe: M5, Continuous contract ES with IB-Data, Candlestick-Style
Backtesting-Mode is "Extended" with Realtime-History-Matching
IntrabarOrderGeneration = true
Wrong opening of a trade when backtesting? (Opened at L instead of O) [SOLVED]
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)
When IntrabarOrderGeneration = true
your order will be triggered in the same bar, as soon as the trade criteria is met.
I not saying this is the problem you are encountering; I just want to make sure we are on the same page.
your order will be triggered in the same bar, as soon as the trade criteria is met.
I not saying this is the problem you are encountering; I just want to make sure we are on the same page.
Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)
Thx for the answer.
It's triggered in the same bar, yes. That part is fine but not as soon as all criteria are met.
In the screenshot is a 10sec resolution and the specific 5 Minute Candle from previous pics marked as a grey box.
Top left the previous trade is getting closed and with live data shortly thereafter the new trade is opened. The new open is at the high because there all strategy criteria were fulfilled but all the bars thereafter the order could have been placed also as the criteria were met all the time.
On the screenshot one can see that thereafter almost the entire candle no trade is opened and the entire time all criteria were fulfilled. The strategy had so many candles with fulfilled criteria but nothing happens. Instead the trade opens at the low. That is not matching the expectations in your quote.
There is second and minute data and by using IntrabarOrderGeneration on M5 that data should be used but it's not. Even data from M1 would trigger the order earlier. IntrabarOrdergeneration doesn't work here.
It's triggered in the same bar, yes. That part is fine but not as soon as all criteria are met.
that is not happening.It does so but not as soon as the trade criteria is met.
In the screenshot is a 10sec resolution and the specific 5 Minute Candle from previous pics marked as a grey box.
Top left the previous trade is getting closed and with live data shortly thereafter the new trade is opened. The new open is at the high because there all strategy criteria were fulfilled but all the bars thereafter the order could have been placed also as the criteria were met all the time.
On the screenshot one can see that thereafter almost the entire candle no trade is opened and the entire time all criteria were fulfilled. The strategy had so many candles with fulfilled criteria but nothing happens. Instead the trade opens at the low. That is not matching the expectations in your quote.
There is second and minute data and by using IntrabarOrderGeneration on M5 that data should be used but it's not. Even data from M1 would trigger the order earlier. IntrabarOrdergeneration doesn't work here.
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)
The uptrends were pushed by the Order opening at the low, gaining great additional performance. Great way to write a stunning strategy in backtest this way.
I remembered about the 'only' OHLC-Check but I was thinking it applies the MinuteData --> calculated down to every 1 Minutebar. Due to the Continuous contract I can't use Bar Magnifier but maybe it's possible via exporting the data series and importing into a new symbol.
Thank You TJ
I remembered about the 'only' OHLC-Check but I was thinking it applies the MinuteData --> calculated down to every 1 Minutebar. Due to the Continuous contract I can't use Bar Magnifier but maybe it's possible via exporting the data series and importing into a new symbol.
Thank You TJ