Hi, i'm trying to recreate a EA to delete pending order when it hit the price i input. But kept having error. tried to google up on the exact word that i should use" (???=My_Price_Target), but not able to. Or maybe the code i do is wrong? anyone could help please? thanks
Brother Mohammad ...
The code is full of errors ... Some are in the functions syntax and some in the logic itself ...
For example ...
--- if (Bid()= Price_Target) should be if (Bid >= Price_Target) or if (Bid <= Price_Target)
it depends on where is the price should be (above or bellow) Price_Target ... using < or > is a must to prevent price tick jump or gaps.
--- Why using ( ) for both Ask and Bid ?
--- Why not use vbid= MarketInfo(Symbol(),MODE_BID) instead of vbid= MarketInfo("Symbol",MODE_BID)
the same for vask
--- add "}" to the end of code.
--- I didn't reviewed the whole logic of the code.
If you tell the needed logic in details, I can help you with full code.
Regards ...
Brother Mohammad ...
The code is full of errors ... Some are in the functions syntax and some in the logic itself ...
For example ...
--- if (Bid()= Price_Target) should be if (Bid >= Price_Target) or if (Bid <= Price_Target)
it depends on where is the price should be (above or bellow) Price_Target ... using < or > is a must to prevent price tick jump or gaps.
--- Why using ( ) for both Ask and Bid ?
--- Why not use vbid= MarketInfo(Symbol(),MODE_BID) instead of vbid= MarketInfo("Symbol",MODE_BID)
the same for vask
--- add "}" to the end of code.
--- I didn't reviewed the whole logic of the code.
If you tell the needed logic in details, I can help you with full code.
Regards ...
- 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'm trying to recreate a EA to delete pending order when it hit the price i input. But kept having error. tried to google up on the exact word that i should use" (???=My_Price_Target), but not able to. Or maybe the code i do is wrong? anyone could help please? thanks
extern double Price_Target=0.0; //The Price at which you want to delete all Pending Orders. extern string Profit_Target= "ENTER ABOVE THE PRICE YOU TARGET"; double vbid= MarketInfo("Symbol",MODE_BID); double vask= MarketInfo("Symbol",MODE_ASK); int Slippage=5; int i; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (vask()= Price_Target) if else (vbid()= Price_Target) { for(i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close pending orders case OP_BUYLIMIT : result = OrderDelete( OrderTicket() ); case OP_BUYSTOP : result = OrderDelete( OrderTicket() ); case OP_SELLLIMIT : result = OrderDelete( OrderTicket() ); case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } { if (Bid()= Price_Target) { for(i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close pending orders case OP_BUYLIMIT : result = OrderDelete( OrderTicket() ); case OP_BUYSTOP : result = OrderDelete( OrderTicket() ); case OP_SELLLIMIT : result = OrderDelete( OrderTicket() ); case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { Sleep(0); } } Print ("Account Price Reached. All Pending Order Have Been Deleted"); return(0); } Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(), "\nMy Account Profit Target: ",Price_Target); return(0);