Please find attached troubleshooting files for individual strategies and the merged portfolio example.
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.
Status changed from Waiting for information to New
Attachment Custom Comment.png added
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
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);
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).
Status changed from New to Fixed
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
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