[Build 112] Many errors in MT4 with exported code from SQX (previously a SQ3 strategy) and other backtesting issues

This is part of a log of an MT4 backtest of an EA that exported to MQ4 from SQX and was previously a SQ3 strategy that I´ve re-imported into SQX, retested and then exported to MQ4. This is with "ModifyInsteadReplacing": true:




2018.10.18 10:08:06.232 1988.01.04 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: modify #107 buy stop 1.00 EURUSD at 1.30170 sl: 1.29370 tp: 0.00000 ok 2018.10.18 10:08:06.227 1988.01.01 14:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:06.227 1988.01.01 14:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 14:00 Opening order type SELL STOP with price 1.30234. Current market prices: 1.29267 / 1.2926 2018.10.18 10:08:06.227 1988.01.01 14:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2927, min. price allowed: 1.2927, stop/limit order price: 1.2677 2018.10.18 10:08:06.227 1988.01.01 14:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 14:00 Opening order type BUY STOP with price 1.26766. Current market prices: 1.29267 / 1.2926 2018.10.18 10:08:06.227 1988.01.01 13:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 13:00 Modifying order failed 2018.10.18 10:08:06.227 1988.01.01 13:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:06.227 1988.01.01 13:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 13:00 Opening order type SELL STOP with price 1.30238. Current market prices: 1.29267 / 1.2926 2018.10.18 10:08:06.227 1988.01.01 13:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2927, min. price allowed: 1.2927, stop/limit order price: 1.2676 2018.10.18 10:08:06.226 1988.01.01 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 01:00 Modifying order failed 2018.10.18 10:08:06.226 1988.01.01 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:06.226 1988.01.01 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 01:00 Opening order type SELL STOP with price 1.30291. Current market prices: 1.29267 / 1.2926 2018.10.18 10:08:06.225 1988.01.01 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2927, min. price allowed: 1.2927, stop/limit order price: 1.2671 2018.10.18 10:08:06.225 1988.01.01 01:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 01:00 Opening order type BUY STOP with price 1.26709. Current market prices: 1.29267 / 1.2926 2018.10.18 10:08:06.225 1988.01.01 00:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 00:00 Order modified successfuly 2018.10.18 10:08:06.225 1988.01.01 00:00:00  1023 EURUSD H1 SQX EURUSD,H1: modify #106 sell stop 1.00 EURUSD at 1.26412 sl: 1.27212 tp: 0.00000 ok 2018.10.18 10:08:06.225 1988.01.01 00:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1988.01.01 00:00 Modifying order with ticket: 106, SL: 1.27212 and PT: 0 2018.10.18 10:08:06.196 1987.12.31 16:00:00  1023 EURUSD H1 SQX EURUSD,H1: modify #106 sell stop 1.00 EURUSD at 1.26447 sl: 0.00000 tp: 0.00000 ok 2018.10.18 10:08:06.196 1987.12.31 16:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.31 16:00 Opening order type SELL STOP with price 1.26447. Current market prices: 1.28807 / 1.288 2018.10.18 10:08:06.196 1987.12.31 16:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2881, min. price allowed: 1.2881, stop/limit order price: 1.2687 2018.10.18 10:08:06.196 1987.12.31 16:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.31 16:00 Opening order type BUY STOP with price 1.26866. Current market prices: 1.28807 / 1.288 2018.10.18 10:08:06.192 1987.12.31 15:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.31 15:00 Order modified successfuly 2018.10.18 10:08:06.192 1987.12.31 15:00:00  1023 EURUSD H1 SQX EURUSD,H1: modify #106 sell stop 1.00 EURUSD at 1.26451 sl: 1.27251 tp: 0.00000 ok 2018.10.18 10:08:06.192 1987.12.31 15:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.31 15:00 Modifying order with ticket: 106, SL: 1.27251 and PT: 0 2018.10.18 10:08:06.192 1987.12.31 15:00:00  1023 EURUSD H1 SQX EURUSD,H1: modify #106 sell stop 1.00 EURUSD at 1.26451 sl: 0.00000 tp: 0.00000 ok 2018.10.18 10:08:05.922 1987.12.28 08:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:05.921 1987.12.28 08:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.28 08:00 Opening order type SELL STOP with price 1.27874. Current market prices: 1.26127 / 1.2612 2018.10.18 10:08:05.921 1987.12.28 08:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2613, min. price allowed: 1.2613, stop/limit order price: 1.2459 2018.10.18 10:08:05.921 1987.12.28 08:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.28 08:00 Opening order type BUY STOP with price 1.24593. Current market prices: 1.26127 / 1.2612 2018.10.18 10:08:05.917 1987.12.28 07:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.28 07:00 Modifying order failed 2018.10.18 10:08:05.917 1987.12.28 07:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:05.917 1987.12.28 07:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.28 07:00 Opening order type SELL STOP with price 1.27876. Current market prices: 1.26627 / 1.2662 2018.10.18 10:08:05.917 1987.12.28 07:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2663, min. price allowed: 1.2663, stop/limit order price: 1.2459 2018.10.18 10:08:05.268 1987.12.18 12:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.18 12:00 Modifying order failed 2018.10.18 10:08:05.268 1987.12.18 12:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:05.268 1987.12.18 12:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.18 12:00 Opening order type SELL STOP with price 1.25129. Current market prices: 1.24607 / 1.246 2018.10.18 10:08:05.268 1987.12.18 12:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2461, min. price allowed: 1.2461, stop/limit order price: 1.2445 2018.10.18 10:08:05.268 1987.12.18 12:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.18 12:00 Opening order type BUY STOP with price 1.24451. Current market prices: 1.24607 / 1.246 2018.10.18 10:08:05.266 1987.12.18 11:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.18 11:00 Modifying order failed 2018.10.18 10:08:05.266 1987.12.18 11:00:00  1023 EURUSD H1 SQX EURUSD,H1: OrderModify error 130 2018.10.18 10:08:05.266 1987.12.18 11:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.18 11:00 Opening order type SELL STOP with price 1.2513. Current market prices: 1.24727 / 1.2472 2018.10.18 10:08:05.042 1987.12.16 11:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 11:00 Not found time From 2018.10.18 10:08:05.038 1987.12.16 10:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 10:00 Not found time From 2018.10.18 10:08:05.033 1987.12.16 09:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 09:00 Not found time From 2018.10.18 10:08:05.028 1987.12.16 08:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 08:00 Not found time From 2018.10.18 10:08:05.022 1987.12.16 07:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 07:00 Not found time From 2018.10.18 10:08:05.018 1987.12.16 06:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 06:00 Not found time From 2018.10.18 10:08:05.012 1987.12.16 05:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 05:00 Not found time From 2018.10.18 10:08:05.007 1987.12.16 04:00:00  1023 EURUSD H1 SQX EURUSD,H1: 1987.12.16 04:00 Not found time From 2018.10.18 10:08:04.763 1987.12.14 05:00:00  1023 EURUSD H1 SQX EURUSD,H1: - SQ LOG 1987.12.14 05:00 Opening order type BUY STOP with price 1.23733. Current market prices: 1.23917 / 1.2391 2018.10.18 10:08:04.760 1987.12.14 04:00:00  1023 EURUSD H1 SQX EURUSD,H1: Strategy tried to place stop/limit order at incorrect price. Market price: 1.2401, max. price allowed: 1.2401, stop/limit order price: 1.2404





This backtest in MT4 is completely wrong, purely because of all these OrderModify errors. With "ModifyInsteadReplacing: false", the errors reduce, at least no more Order-handling issues. It´s still full of "Not found time from" (although I don´t even use that feature). However, the backtests still don´t match, not even between SQX and MT4. I think I need to address all of this with some screenshots.



Here is the original strategy imported from SQ3 into SQX (not done any retests in SQX, just imported the results from the SQ3 file, so what you see here, is the pure backtests results how they came out of SQ3 with 1 min data mode):
https://image.ibb.co/j55qWL/Screenshot-17.png


Here is the same strategy, but retested with the exact same data, spread, commission and slippage in SQX (Metatrader4 engine, 1 min data mode too):
https://image.ibb.co/fGzTJ0/Screenshot-18.png



At a first look, the differences don´t seem big because we are looking at a 32 years backtest, but they are, if looking at the exact figures. The SQ3 backtest has a net profit of 457267 and 4426 trades. The SQX retest of that strategy has a net profit of 400663 and 3916 trades, that´s a lot!


So let´s take a look at how all of this looks in MT4. We first see the MQ4 code backtest that was exported from SQ3(!), and we see a very nice match to the SQ3 backtest (the amount of trades is almost exactly the same, just 1 trade less! Net profit is different because there is no slippage taken into account in MT4, but the equity curve is almost 100% matching the SQ3 backtest too):
https://image.ibb.co/gTShd0/Screenshot-14.png

https://image.ibb.co/gnYzQf/Screenshot-15.png



Now we take a look at the MQ4 code for this strategy that was exported from SQX and we can easily see, that the MT4 backtest does not just NOT match the old SQ3 backtest, but even compared to the new SQX backtest (which is off by itself already compared to the SQ3 backtest too, as we saw above) it is completely off now:
https://image.ibb.co/egM0y0/Screenshot-19.png

https://image.ibb.co/duHvWL/Screenshot-20.png



I would have at least expected that new SQX backtest would match the MQ4 code that was exported from SQX, but on that front it still seems to be a hit and miss (works for some strategies, but does not work for many either). Hope this all is going to work one day, but right now it´s all extremely messy as "nothing seems to match with nothing".

Attachments
No attachments
  • Votes +3
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

g
#1

geektrader

18.10.2018 11:43

Task created

g
#2

geektrader

18.10.2018 11:43
Voted for this task.
g
#3

geektrader

31.10.2018 09:49
Any news on this rather serious problem?
TB
#4

Tomas Brynda

31.10.2018 11:15

Status changed from New to Waiting for information

Please attach the SQ3 strategy otherwise I can't investigate it further
b
#5

bentra

31.10.2018 12:45
I had a problem too with an old sq3 strat. I could not walkf forward something about the variable not imported "replaceorders." I had to use 7-zip to edit the compressed strategy file, found an xml with the offending variable and removed the variable and everything worked fine. 
g
#6

geektrader

31.10.2018 19:20
Tomas, I´ve emailed you the strategy as I can´t share it in public.
IH
#7

clonex / Ivan Hudec

02.11.2018 09:43
Voted for this task.
TB
#8

Tomas Brynda

05.11.2018 07:01

Status changed from Waiting for information to Fixed

I fixed Highest/LowestInRange MQL code, the strategy gives me matching results now
g
#9

geektrader

05.11.2018 07:15
Great, thanks. I will report back how it goes now.
m
#10

Martin

07.11.2018 07:49
Voted for this task.

Votes: +3

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please