I am using MT4 for automated trading. The situation goes like this.
The EA I am using is placing multiple orders per bar. See the image below where it placed 10 orders in a 30M bar.
How can I modify an expert advisor in MQL4 so that it places only one order per bar?
Any help would be highly appreciated.
Include a flag which will turn on once a order is placed and should turn off at new bar. If this flag is on then no further trades. Let me know if you have difficult in implementing this.
Hello many thanks for your answers.
I tried to include a flag as sineshydv suggested. I am not quite sure if this will work. So far there have been no multiple orders.
Here is the order's dispatch part of the code. In red fonts are the modifications I did. Do you think this is going to work?
int OpenOrder(int Typ, double Lots, int OrderSlippage, string Orderkommentar, int Magicnumer, color FareVonOrderPfeil)
I think you should move the position of "static datetime lastOrderSend;" like this:
static datetime lastOrderSend;
Since this is MQl4 you may get more help if you post it in www.mql4.com
and use src button to post code