why my EA opened 200 order?

 

there is on my EA order count control code, my code check orders in this way: "if there is one or more SELL order do not open another SELL order".

i set  MT4 as if cut off electric and computer get reseted my MT4 and EA will opening automatically. 

Today my computer getting reseted and opening and opened MT4 and EA automatically.

But my EA opened 200 SELL orders.

How can i prevent this situation? To not open many order on starting.

Thank you.

 
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
 
whroeder1:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

Thank you, you all right :)

My code is this. After reseting of computer the metatrader4 open automatically with my EA. Then my EA open 200 SELL orders.

Whereas i coded that open only one sell order if there is not  buy and count sell and count buystop and sellstop order.

i want to my EA open only one order with this code when computer reset/restart.


void OnTick()
  {
if(CountBuy(Buy_01)<=0 && CountBuyStop(Buy_01)<=0 && CountSell(Sell_01)<=0 && CountSellStop(Sell_01)<=0){
      if(!OrderSend(Symbol(),OP_SELL,lot01,Bid,slippage,0,0,Sell_01,Sell_01,0,Brown)){
         SendNotification("ERR:"+AccountCompany()+","+GetLastError()); } }
............
...........
........
 
to60:

Thank you, you all right :)

My code is this. After reseting of computer the metatrader4 open automatically with my EA. Then my EA open 200 SELL orders.

Whereas i coded that open only one sell order if there is not  buy and count sell and count buystop and sellstop order.

i want to my EA open only one order with this code when computer reset/restart.



You coded EA to open an infinite number of sell orders (or as much as your account can handle), but your broker does not allow more than 200 active orders.

Check your "CountXXX" functions, they obviously have bug(s).

 
  1. That isn't just your code. Your code also includes CountBuy CountBuyStop, CountSell and CountSellStop, and those variables (Buy_01 and Sell_01.) We can't see your broken code.
  2. OrderSend does not return a bool. Non-zero is true: you will always send the notification.
 
to60:

there is on my EA order count control code, my code check orders in this way: "if there is one or more SELL order do not open another SELL order".

i set  MT4 as if cut off electric and computer get reseted my MT4 and EA will opening automatically. 

Today my computer getting reseted and opening and opened MT4 and EA automatically.

But my EA opened 200 SELL orders.

How can i prevent this situation? To not open many order on starting.

Thank you.

you might have placed a piece which send an order to your broker inside a For Loop
Reason: