Merge Functionality (Trading in Parrallel)

Build 130 unlike prior builds seems to have a problem when compiling code for merged strategies (in this instance for MT4). The merged portfolio EA is not correctly coding component EAs. The combined merged result is materially different to the individual component strategies.



Please find attached troubleshooting files for individual strategies and the merged portfolio example.

Attachments
Troubleshoot.zip
(306.27 KiB)
  • Votes +1
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

RB
#1

ATS118765

06.01.2021 06:33

Task created

TB
#2

Tomas Brynda

06.01.2021 07:54

Status changed from New to Waiting for information

Hi,

I tried to compile the portfolio mql code and it has succeeded. When going through the strategies logic I can't see anything suspicious.


Can you explain what exactly is wrong?


Best regards,

Tomas

RB
#3

ATS118765

08.01.2021 03:30
Hi Tomas


I think the problem lies in the merge function relating to the number of trades taken per day. For example, assume I have created 7 individual strategies that only allow 1 trade per day on the daily timeframe.


When I merged the strategies in parrallel in Build 129, I would specify a maximum number of trades per day for the compiled portfolio EA to 7 trades per day. This would be respected and there would never be greater than 7 trades running at a time.


Now with Build 130 if I specify any number of trades per day....then this rule is not respected.

o
#4

Enric

08.01.2021 19:27
Voted for this task.
TB
#5

Tomas Brynda

11.01.2021 11:29

Status changed from Waiting for information to New

Ok thanks for the info, I'll check that
RB
#6

ATS118765

24.01.2021 01:06

Attachment Custom Comment.png added

Custom Comment.png
(317.95 KiB)

Hi Tomas


I have found the problem with the Merge function (trading in Parrallel) that has arisen in Build 130. 


The problem arises when you use a verbose description of component strategies to merge into a single portfolio that exceeds 30 characters.


When you look at the code for the portfolio the file is structured with a number of variables numbered from one to how ever many strategies there are and for each individual EA there is a CustomComment as shown.


Have a look at one such comment:

extern string CustomComment2 = "Cocoa D1 DON SMA Breakout_Strategy 0.49329";

 

while its nice to have a detailed comment description, this is in fact the problem. This field is tooooooooo longgggggg, and needs to be less that 30 characters.

This simple fix solves the problem of multiple trades being fired off on each signal even when there are trades open.


In the merged portfolio it compares the Custom Comment 2 above against the 30 character  text string and hence does not find a match. This results in the errors arising in trade number and results of the merged portfolio.


If I keep the description of each component EA to below 30 characters....it works fine.


Cheers


Rich 



h
#7

hankeys

24.01.2021 10:32
there should be code for stretching the comments,but question is if its working for merged EAs 


   string commentToUse = "";

   if(comment != ""){

      commentToUse = comment;

   }

   else {

      commentToUse = CustomComment;

      StringReplace(commentToUse, "Optimization", "Opt.");     //shorten the name of optimized strategies

   }

   commentToUse = StringSubstr(commentToUse, 0, 30);           //limit the length to 30 characters


   int ticket = OrderSendReliable(correctedSymbol, orderType, size, price, correctSlippage(sqMaxEntrySlippage, correctedSymbol), 0, 0, commentToUse, magicNumber, expirationInTime, arrowColor);


   if(ticket > 0) {



every strategy has his own comment, but first comment is not used in the action, after magicnumber, the comment field is empty


// Action #1

         _ticket = sqOpenOrder(OP_BUYSTOP, "Subchart1Symbol", sqMMRiskFixedBalancePct("Subchart1Symbol",OP_BUYSTOP,(sqGetAsk("Subchart1Symbol") + (0.20 * sqBBWidthRatio(Subchart1Symbol, Subchart1Timeframe, 195, 5, PRICE_LOW, 3))),sqGetSLLevel("Subchart1Symbol", OP_BUYSTOP, (sqGetAsk("Subchart1Symbol") + (0.20 * sqBBWidthRatio(Subchart1Symbol, Subchart1Timeframe, 195, 5, PRICE_LOW, 3))), 1, 40),mmRiskPercent,mmDecimals,mmLotsIfNoMM,mmMaxLots), (sqGetAsk("Subchart1Symbol") + (0.20 * sqBBWidthRatio(Subchart1Symbol, Subchart1Timeframe, 195, 5, PRICE_LOW, 3))), MagicNumber, "", 0, false, false, CLR_NONE);

RB
#8

ATS118765

25.01.2021 00:26
With merged strategies whose comment fields are less than 30 characters I can confirm that the merge function is working.


I took the individual strategies and the Merged EA to MT4 and ran 30 year backtests to generate trade results. I then uploaded test results to QA to compare results between the compiled result and the Merged Portfolio trade result.


The results confirm that the merge functionality works (provided the 30 characters or less in the comments is satisfied).

TB
#9

Tomas Brynda

01.02.2021 11:20

Status changed from New to Fixed

Hi ATS118765,

thank you for pointing out the problem with comments.

You are right, it really has a negative impact on strategy trading.


I have improved both MQL4 and MQL5 code to check the comments length on init and throw an alert if it is too long.

That should help to avoid any future issues with comments.


Best regards,

Tomas


Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please