Duplicate Journal Messages | MT4

 
Hello All

So I have an EA which, itself, is executing perfectly, but I'm getting duplicate Journal messages. As you will see below, there are a vast number of duplicated journal messages, which I believe have resulted in Error #4025 - which is an OUT OF MEMORY issue.

These are not duplicated Print() functions in my EA - these are default MetaTrader Journal messages.

In addition, apparently I'm closing my positions with a price of 0.00000, again these are not EA-coded Print() functions.  

The below was the result of my EA shorting 6 lots of the GBPCAD, closing 50% of my position and modifying my s/l to breakeven.

for(int s = OrdersTotal()-1; s>= 0; s--){

        if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES) && Symbol() == OrderSymbol() && Period() == OrderMagicNumber()){

                /*...............*/
		/*...............*/
		/*CODE FOR BUTTON WHICH CLOSES POSITION WITH*/
                /*...............*/
                /*...............*/

        } else  {

                Print("Please report error #"+IntegerToString(lastError,0));

        }

}

0       14:00:00.074    '6846142': order sell market 6.00 GBPCAD sl: 1.61445 tp: 1.60966
0       14:00:00.183    '6846142': order was opened : #106684376 sell 6.00 GBPCAD at 1.61349 sl: 1.61445 tp: 1.60966
0       14:00:00.339    Notifications: 'order opened #106684376 sell 6.00 GBPCAD at 1.61349 sl: 1.61445 tp: 1.60966, <Account Name>' sent to '<MT4 App Identifier>'
0       14:33:03.419    '6846142': modify order #106684376 sell 6.00 GBPCAD at 1.61349 sl: 1.61445 tp: 1.60966 -> sl: 1.61349 tp: 1.60966
0       14:33:03.419    '6846142': modify order #106684376 sell 6.00 GBPCAD at 1.61349 sl: 1.61445 tp: 1.60966 -> sl: 1.61349 tp: 1.60966
0       14:33:03.591    '6846142': order #106684376 sell 6.00 GBPCAD at 1.61349 was modified -> sl: 1.61349 tp: 1.60966
0       14:33:03.591    '6846142': order #106684376 sell 6.00 GBPCAD at 1.61349 was modified -> sl: 1.61349 tp: 1.60966
0       14:33:03.591    '6846142': close order #106684376 sell 3.00 GBPCAD at 1.61349 sl: 1.61349 tp: 1.60966 at price 0.00000
0       14:33:03.591    '6846142': close order #106684376 sell 3.00 GBPCAD at 1.61349 sl: 1.61349 tp: 1.60966 at price 0.00000
0       14:33:03.716    Notifications: 'order #106684376 sell 6.00 GBPCAD at 1.61349 modified: sl: 1.61445 tp: 1.60966 -> sl: 1.61349 tp: 1.60966' sent to '<MT4 App Identifier>'
0       14:33:03.763    '6846142': order #106684376 sell 3.00 GBPCAD at 1.61349 sl: 1.61349 tp: 1.60966 closed at price 1.61145
0       14:33:03.763    '6846142': remainder of order #106684376 was opened : #106685771 sell 3.00 GBPCAD at 1.61349 sl: 1.61349 tp: 1.60966
0       14:33:03.872    Notifications: 'order #106684376 sell 3.00 GBPCAD at 1.61349 closed at price 1.61145, to #106685771, profit: 379.78 GBP' sent to '<MT4 App Identifier>'
0       14:33:03.919    Notifications: 'order opened #106685771 sell 3.00 GBPCAD at 1.61349 sl: 1.61349 tp: 1.60966, from #106684376' sent to '<MT4 App Identifier>'
0       14:35:50.226    Notifications: 'Ticket #106684376 has closed with a profit of 379.78' sent to '<MT4 App Identifier>'
 
for(int s = OrdersTotal()-1; s>= 0; s--){

        if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES) && Symbol() == OrderSymbol() && Period() == OrderMagicNumber()){

                
           //Executed if order is selected AND is the chart symbol AND is the stipulated magic number 

        } else  {

                
           //Executed if the order is NOT selected OR not the chart symbol OR is not the stipulated magic number 
        }
 
Keith Watford #:

Thanks Keith :) 

I did do some jiggery pokery around with this, and separated out the OrderSelect, the Symbol and the stipulated Magic Number.

Because this EA is over around 20 instances, it would - of course - select the order but because the symbol would have been different on the other instances, it would naturally result in error messages from instances where no errors were occurring. Separating these out should resolve the issue.