Wrong opening of a trade when backtesting? (Opened at L instead of O)  [SOLVED]

Questions about MultiCharts and user contributed studies.
PK1
Posts: 79
Joined: 12 Jun 2011
Has thanked: 32 times
Been thanked: 8 times

Wrong opening of a trade when backtesting? (Opened at L instead of O)

Postby PK1 » 10 May 2018

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
Chart 00018.jpg
Chart 00018.jpg (41.39 KiB) Viewed 606 times
Chart 00019.jpg
Chart 00019.jpg (32.27 KiB) Viewed 606 times

User avatar
TJ
Posts: 7192
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)

Postby TJ » 10 May 2018

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.

PK1
Posts: 79
Joined: 12 Jun 2011
Has thanked: 32 times
Been thanked: 8 times

Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)

Postby PK1 » 10 May 2018

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.
It does so but not as soon as the trade criteria is met.
that is not happening.

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.
Chart 00021.jpg
Chart 00021.jpg (42 KiB) Viewed 601 times

User avatar
TJ
Posts: 7192
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)  [SOLVED]

Postby TJ » 10 May 2018

See post #4
[FAQ] Autotrade / Backtest / Optimization
viewtopic.php?t=10811

PK1
Posts: 79
Joined: 12 Jun 2011
Has thanked: 32 times
Been thanked: 8 times

Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)

Postby PK1 » 10 May 2018

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

PK1
Posts: 79
Joined: 12 Jun 2011
Has thanked: 32 times
Been thanked: 8 times

Re: Wrong opening of a trade when backtesting? (Opened at L instead of O)

Postby PK1 » 11 May 2018

The original topic is solved yes but the point that those trades don't occur during playback while all other trades do, that can't be right.


Return to “MultiCharts”