110 - Trading logic does not allow open limit orders to stay active for xx bars.

110 - Trading logic does not allow open limit orders to stay active for xx bars.

The strategy was originally generated in SQ 3.8.2 where it had 608 trades and $2,033 profit.
The MT4 program generated by SQ 3.8.2 had 636 trades with $1,559 profit.
When it was imported into SQ4 the results were 630 trades with $4,464 profit.
When the SQ4 strategy was converted to MT4, the backtest took so long that I killed it after 6 hours. The SQ3 MT4 progran ran in 17 minutes.

Looking at the MT4 tester logs for both EAs revealed the difference.  
In the 3.8.2 version immediatly creates a buy and a sell stop order and then modifies them to place the SL and TP. Those orders are closed 9 to 10 (it should always be 9 hours) hours later and replaced by new buy and sell stop orders. The cycle repeats until an order is executed then it is managed until closed.

The SQ4.110 MT4 program results differs drastically. Like the 3.8.2 version it immediatly creates a buy and a sell stop order then those two orders are modified for SL and TP. What happens next causes the discrepancy:
The SQ4 -> MT4 program does not allow the existing limit orders to stay active until the expiration period expires. It seems, that after the first 2 bars, it opens new limit orders and deletes the old orders on every new bar.
IMPORTANT FOR DEBUGGING -> The next order is opened BEFORE the old order is deleted - it is part of the int sqOpenOrder() function.

The .7z files include the strategies for each version, reports and log files from the MT4 tester.
Attachments
SQ 382 files for Strategy 1389_5.7z
(1.29 MiB)
SQ4 Files for Strategy 1389_5.7z
(440.98 KiB)
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

d
#1

Dave

12.09.2018 00:38

Task created

d
#2

Dave

16.09.2018 02:28

Tomas,

This bug may actually a good thing except most brokers will allow so many orders opened and closed.  I am testing over 300,000 strategies generated by SQ3 and have found numerous strategies that when traded this way, replacing the orders every hour, are up to 50% more profitable than their SQ3 version. The best way to code this method of replacing orders every hour would probably be having the MT4 program maintain the pending order and monitor the bid/ask to perform a market entry. Could this be generated using the SWWizard?

I would like to know your thoughts on this.

Thank you,

Dave

TB
#3

Tomas Brynda

17.09.2018 07:47

Status changed from New to In progress

Hi Dave,

I am currently backtesting the strategy. I made some changes in import to SQX and the results between SQX and SQ3 are more similar now.


To your question - If you haven't done it yet, please try to set ModifyInsteadOfReplacing parameter of the EA to true. It should cause pending orders to be modified rather than replaced by new ones. The backtest is much faster with this option.


Tomas

d
#4

Dave

17.09.2018 14:43
I have looked for the  ModifyInsteadOfReplacing parameter and could not find it. Could you tell me where it is located?  I am sure that I will say "Now why couldn't I see that It is plain as day!"

Thanks,

Dave

TB
#5

Tomas Brynda

17.09.2018 15:25
It is located in Expert properties -> Inputs in the MT4 Tester. 
TB
#6

Tomas Brynda

14.10.2018 19:03

Status changed from In progress to Fixed


Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please