Download MetaTrader 5

Multiple Duplicated Orders

To add comments, please log in or register
Dear Sir / Madam,

Since a few months ago, I started programming on MT4.

I have encountered a problem which requires help:

This problem happened before but later went away for unknown reasons, but this time it persists.

Please kindly refer to the attached image: MT4 Duplicated Orders.jpg

You will see 2 charts on top and a list of alerts below the 2 charts.

Both are M5 charts. The one on the left is the expanded M5 chart and that on the right is the squeezed M5 chart. The green lines are the order positions and the red lines are the stop losses.

You can see that many orders took places at 2 different bars. I calculated, altogether there are 46 orders taken. However, my program only allows one order taken at a time.

If you look at the alert list, the tickets are 0 before the ordersend() command. After the ordersend() command, order taken and the ticket number is alerted. Nothing in the program would change the ticket number to 0 unless the order is closed. The program is written such that ticket must be 0 before it can satisfy one of the conditions to reach ordersend() command. Looking at the program, there is no way the ticket can be reset to zero and get into the ordersend() again after the order is taken. Only when the order is closed, the ticket number is set to 0.

The sequence of program to print the alert is as follows:

ErrAlert = StringConcatenate(Symbol(),"  SELL ","  NumBar =",NumBar,"    SellTicket = ",SellTicket);
Alert (ErrAlert);
SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,OpenSellPrice,UseSlippage,SellStopLoss,0,"Sell Order",MagicNumber,0,Green);
ErrAlert = StringConcatenate(Symbol(),"   SellTicket = ",SellTicket);
Alert (ErrAlert);

Please note that on top of the alert list is the last alert and the ticket number shows -1. Before that it is 0.

With ticket= -1, no more order is taken.

By the way, this problem occurred, I believe, while I had the EA running on the chart and I tried to edit and compiled the edited EA.

I suspect there is something hidden in MT4 which caused this to happen. However, not every time 46 orders are taken. Sometimes, 3 orders taken, other time a few. The numbers vary. This was the first time I saw that it happened at 2 different bars.

Can you enlighten me, please?

Your sincerely,
Alain Verleyen
Alain Verleyen  
Fix your code. We can't help without your code.
To add comments, please log in or register