SQX v126 – Massive Slow-down in MT4 Backtest Performance between SQ 3.8.2 and SQX v126

Hi Mark

Please see attached the following 2x sets of SQ strategy + associated MT4 files:


1. 20170617d_Strategy 0.48690_01.str (EURUSD_H1_20170617d_Strategy 0.48690_01.mq4)

  • Both legacy *.str and *.mq4 files, generated in SQ 3.8.2
  • Backtest time in MT4: 27min

2. WF Matrix - 20170617d_Strategy 0.48690_01_20191206 25% MM.sqx (EURUSD_H1_WFM - 20170617d_Strategy 0.48690_01_20191206 25% MM.mq4)

  • Created from above SQ 3.8.2 *.str file, imported into SQX v126 Optimizer for WFM processing. See attached *.cfx setting file
  • *.sqx file saved in SQX v126 format
  • *.mq4 file generated in SQX v126
  • Backtest time in MT4: 3days, 12hrs, 33min

MT4 backtest setup was identical for both MT4 files:

  • Latest issue: MT4, v4.00, Build 1220
  • EURUSD, H1
  • From 2003.05.05; To 2019.12.29
  • Birt’s Tick Data Suite
  • Every tick, most precise
  • Dukascopy tick data

In essence, the difference between the above 2x MT4 files should be a difference in WFM optimized parameter values only. Otherwise the strategies should function the same. However, the SQX v126 generated MT4 code took ~188x longer to perform the backtest than did the original SQ 3.8.2 generated MT4 code. Otherwise the SQX v126 MT4 code performed a successful backtest.


Please can you investigate what has gone wrong with the SQX generated MT4 code, causing this massive slow-down in MT4 backtest performance, and look into correcting the problem for next up-issue of SQX.


Thanks

AC1962

Attachments
WFM Optimize_01.cfx
(3.02 KiB)
20170617d_Strategy 048690_01.str
(1.01 MiB)
EURUSD_H1_WFM - 20170617d_Strategy 048690_01_20191206 25 MM.mq4
(206.71 KiB)
WF Matrix - 20170617d_Strategy 048690_01_20191206 25 MM.sqx
(212.93 KiB)
EURUSD_H1_20170617d_Strategy 048690_01.mq4
(73.74 KiB)
  • Votes +4
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

AC
#1

AC1962

02.01.2020 13:02

Task created

k
#2

Krit

09.01.2020 11:51
Voted for this task.
AC
#3

AC1962

18.02.2020 00:23

Attachment EURUSD_M15_WFM - 20160819d_Strategy 081149_01_20191206 25 MM.mq4 added

Attachment EURUSD_M15_20160819d_Strategy 081149_01.mq4 added

Attachment 20160819d_Strategy 081149_01.str added

Attachment WF Matrix - 20160819d_Strategy 081149_01_20191206 25 MM.sqx added

Hi Mark

Following on from my initial bug report: sq4_5833. I have now re-processed a portfolio of 5x existing SQ 3.8.2 strategies using SQX v126 WFM. 3x of which test in MT4 + TDS in good time, but the previous reported strategy, and 1x other, are now taking many days to test in MT4, for what previously took less than 1.5hrs in total to test both:

  • 3.5 days for previously reported strategy
  • So far 6.5 days for attached additional strategy, and so far barely progressed 40%
As you can imagine this is a real pain and very disappointing to see. Previously it took me max 3hrs to test all 5x strategies in MT4, which I did once a month to re-balance my portfolio. Now with SQX it is no longer practical for me to re-balance these 2x strategies.


Please can you urgently investigate and report back why the new SQX v126 generated MT4 code has become so inefficient to test in MT4, compared to original SQ 3.8.2 generated MT4 code? While in essence both strategies should function the same as previous, with only a change in parameter values.


Thanks

AC1962

h
#4

hankeys

18.02.2020 11:47
replace pending order to true and low value for bars valid could be a problem
AC
#5

AC1962

18.02.2020 12:15

Attachment SQX 126 - Strategy parameters AC20200218.png added

Hi hankeys

Thanks for your response. However, I can find no parameter "replace pending order" in SQX v126 generated *.sqx file. Did you mean "replace existing orders"? See screenshot image.

Thanks

AC1962

h
#6

hankeys

19.02.2020 06:49
i mean this code in the strategy itself and what you can set in building task


Open Short order at Highest(Main chart, 14, PRICE_OPEN)[1] Stop;
Order valid for 2 bars;
Duplicate trades: disabled;
Replacing pending orders: allowed;
Stop Loss = 450pips;


for example this strategy is for M15 timeframe and have allowed replacing pending orders and order is valid only 2 bars...so every 15 minutes will the pending order be modififed and every 30 minutes will be deleted and if the entry conditions are still true, new pending order will be placed


so if you are doing tick backtest in MT4 (tick data suite) this backtest will last hours, days

AC
#7

AC1962

20.02.2020 00:19
Hi hankeys

Thanks for your message: a helpful tip. However, only the SQ 3.8.2 generated MT4 code includes variable 'ReplacePendingOrders'. The SQX v126 generated MT4 code does not.

The M15 strategy in SQ 3.8.2 generated MT4 code took 74min to run with variable 'ReplacePendingOrders = TRUE', reducing to 37min with variable 'ReplacePendingOrders = FALSE'. Either of these test times are fine with me. Whereas the same strategy in SQX v126 generated MT4 code takes 6 days to progress barely 40% through the MT4 test. At which point I gave up.

This massive slow-down in MT4 backtest performance suggests something else within the SQX v126 generated MT4 code being the cause, not either of the 2x variable values that you have suggested.

Thanks again

AC1962

b
#8

bentra

20.02.2020 22:46
Voted for this task.
Rr
#9

Partizanas

25.03.2020 14:08
Voted for this task.
h
#10

hankeys

26.04.2020 10:54
replacing pending orders set to true will slow down the backtest

and its normal behavior, because with every candle the EA need to recompute everything


if this could be done better, who knows...i am not a MQL programmer, but its true, that SQ3 code doenst do this

TB
#11

Tomas Brynda

07.05.2020 10:06

Status changed from New to Waiting for information

Hi AC1962,

I noticed that in your EA from SQX there is a ModifyInsteadOfReplacing set to false. 

Please try to set this parameter to true, I believe the backtest will be much faster.


Let me know if it helped.


Best regards,

Tomas

h
#12

hankeys

07.05.2020 11:39
but this setting is originally set to false from SQX template


extern bool ModifyInsteadOfReplacing = false;

TB
#13

Tomas Brynda

08.05.2020 08:41
Hankeys: Yes, it is, because this setting can sometimes cause differences in backtest results.

Modifying changes only open price, SL and PT. The volume is ignored - it is not a wanted behaviour when using other money management methods than Fixed size.


But if you use the simple fixed size MM, this setting can speed up the backtest in MT4, especially if the strategy produces a lot of trades.

AC
#14

AC1962

08.05.2020 16:42

Thanks hankeys!

 

Hi Tomas

 

Yes, changing setting ModifyInsteadOfReplacing = TRUE does significantly improve progress in MT4: <1hr in both cases, which is excellent. Thanks!

 

However, from what I can see, ModifyInsteadOfReplacing = FALSE is default set by SQX (as hankeys has mentioned), not user set by me. While I appreciate that changing this setting vastly improves the MT4 test time, does not changing this setting also change the strategy that SQX generated and thereby possibly negate all the effort involved in filtering, robustness testing & WFM testing that I have already undertaken in SQX, prior to even starting any final MT4 testing?

 

If, to resolve this issue in future, I need to modify ModifyInsteadOfReplacing = TRUE at MT4 stage, then I request that SQX should either: use ModifyInsteadOfReplacing = TRUE by default, not FALSE; or allow the user, possibly in Builder \ Trading Options, to set ModifyInsteadOfReplacing = TRUE prior to Building any strategies.

 

Thanks

AC1962

h
#15

hankeys

08.05.2020 21:12
Voted for this task.
TB
#16

Tomas Brynda

11.05.2020 10:18

Status changed from Waiting for information to Fixed

The ModifyInsteadOfReplacing parameter simply modifies the last existing pending order in the same direction (updates its open price, SL and PT) instead of creating a new order and cancelling the previous one. This results in much smaller number of history trades and it often leads to a much faster backtest.


It is completely fine to use this feature if you use fixed size money management, the results should be exactly the same. The problem is when using other types of MM, because the modification doesn't support changing pending order's size.

If you set ModifyInsteadOfReplacing = true and used for example Risk Fixed % Of Account MM and the strategy tested had a variable SL (not fixed pips), the trade volumes would be probably different from backtest with ModifyInsteadOfReplacing = false. 


Because of this I think it would be better to leave this param set to false by default. The experienced users can simply toggle it to true manually if they want to.


Best regards,

Tomas

AC
#17

AC1962

18.05.2020 00:00
Hi Tomas

Thanks for you explanation. However, given the problems I have experienced with this feature in SQX (never with SQ 3.8.2) during MT4 backtesting, I request you consider giving the user the option to select ModifyInsteadOfReplacing = 'True' or 'False' at Builder setting stage, not fix the value as 'False' only. This way I can choose to avoid Builder generating any strategies that are likely to result in such impractically long MT4 backtest durations.

Thanks

AC1962 

TB
#18

Tomas Brynda

18.05.2020 16:20
Hi AC1962,

thank you for your suggestion, but I think this setting would unnecessarily complicate the UI.


I will set this parameter to true by default and add a condition to the MQL template not to ModifyInsteadOfReplacing in case the volume of the new order is different.


Best regards,

Tomas

AC
#19

AC1962

18.05.2020 23:43
Great, thanks Tomas!

AC1962


Votes: +4

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please