Need a guide to edit my EA

 

Hello guys,

I'm newbie in programming MQL4 and I'm facing a major problem while I was creating my first EA... My EA always places multiple orders in one time with the same price. I was wondering if anybody in the forum who are more senior can guide me how to edit my EA so it can only place an order (buy/sell) at every price condition.

Thanks.

Best Regard

Files:
 

You need this thread https://www.mql5.com/en/forum/174329 : there is some links like 'one order per chart' for example.

 

This is what I use.

int buy_orders = 0, sell_orders = 0;

int i;

int cnt = OrdersTotal();

for (i=0;i<cnt;i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)

if (OrderType() == OP_BUY) buy_orders++;

else if (OrderType() == OP_SELL) sell_orders++;

}

I always put this at the start of every ea and then check that there are no existing orders in the logic section.(I borrowed it from someone else!)

if(sell_orders<1 && etc....

Reason: