Hi, i already recreate an EA to what i want but i'm having issues... all error been fix.. but the EA close all pairs orders.. I just want the EA to close on 1 pair which the EA been placed... Could tell me where is the error?
Hi Mohammad,
two things I'm missing in the code of the start procedure:
int start() { if((BUY && iClose(NULL,0,1)<=Price_Target && Ask <= Price_Target) || (SELL && iClose(NULL,0,1)>=Price_Target && Bid >= Price_Target)) { for(i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); if (OrderSymbol() != Symbol()) continue; int type = OrderType(); bool result = false; switch(type) { case OP_BUYLIMIT : result = OrderDelete( OrderTicket() );break; case OP_BUYSTOP : result = OrderDelete( OrderTicket() );break; case OP_SELLLIMIT : result = OrderDelete( OrderTicket() );break; case OP_SELLSTOP : result = OrderDelete( OrderTicket() );break; case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );break; case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );break; } if(result == false) { Sleep(0); } } Print ("Price Reach!! All Orders Have Been Closed & Deleted"); return(0); } Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(), "\nMy Account Profit Target: ",Price_Target); return(0); }
See the added statements written in bold letters:
- for limiting the orders on your current symbol you have to add
if (OrderSymbol() != Symbol()) continue;
- do not forget the break statements within the switch clause
iClose(NULL,0,1)
is correct
Matthias/Bobcat
Hi Mohammad,
two things I'm missing in the code of the start procedure:
See the added statements written in bold letters:
- for limiting the orders on your current symbol you have to add
- do not forget the break statements within the switch clause
is correct
Matthias/Bobcat
Hi Mohammad,
two things I'm missing in the code of the start procedure:
See the added statements written in bold letters:
- for limiting the orders on your current symbol you have to add
- do not forget the break statements within the switch clause
is correct
Matthias/Bobcat
Could you explain to why i need to put a the break statements within the switch clause? thank you. just for my learning.
Dr Matthias,
Could you explain to why i need to put a the break statements within the switch clause? thank you. just for my learning.
You can inform you further about the switch statement eg in the MQL4 Reference / Language Basics / Operators / Switch Operator
or look into the following page:
http://www.tutorialspoint.com/cprogramming/switch_statement_in_c.htm
Matthias/Bobcat

- tutorialspoint.com
- www.tutorialspoint.com
Thank you Dr Matthias. did the changes and all is good and working as to what i want. thank you so much for guiding me.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, i already recreate an EA to what i want but i'm having issues... all error been fix.. but the EA close all pairs orders.. I just want the EA to close on 1 pair which the EA been placed... Could tell me where is the error?
Is the error on either of this?
or
And also,
NULL is the current symbol right? followed by 0 means the current TF am i right? or i must put NULL in order for it to get the info from current TF?
Thank You