- Is My Code here Correct?
- How do i arrange or the IF ELSE Functions
- I know there is errors here... i need help... it won't trigger
int start() { if((CLOSE_ORDER_PRICE_BUY && (Bid>=BUY_TAKE_PROFIT || Ask<=BUY_STOP_LOSS))) { for(i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i, SELECT_BY_POS) || OrderSymbol()!=_Symbol) continue; int type = OrderType(); bool result = false; switch(type) {case OP_SELLSTOP : result = OrderDelete( OrderTicket() );} if(result == false) {Sleep(0);} } Print ("!!ORDER CLOSE!!ORDER CLOSE!!"); return(0); } if((CLOSE_ORDER_PRICE_SELL && (Ask<=SELL_TAKE_PROFIT || Bid>=SELL_STOP_LOSS))) { for(i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i, SELECT_BY_POS) || OrderSymbol()!=_Symbol) continue; switch(type) {case OP_BUYSTOP : result = OrderDelete( OrderTicket() );} if(result == false) {Sleep(0);} } Print ("!!ORDER CLOSE!!ORDER CLOSE!!"); return(0); } Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(), " ","ORDER CLOSE"); return(0); }
Above is part of the code
It doesn't delete the Stop/Limit order once Bid/Ask hit the Price stated....What i'm trying to do is, I have an open order and Stop Order. If Bid/Ask reach XXXXXX price, it will delete the Stop Order
- www.metatrader5.com
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
Thank you.
Done
Done
So, what "does not work" in particular?
So, what "does not work" in particular?
It doesn't delete the Stop/Limit order once Bid/Ask hit the Price stated....
What i'm trying to do is, I have an open order and Stop Order. If Bid/Ask reach XXXXXX price, it will delete the Stop Order
Here is your code simplified. It looks like you may have an issue with your upstream logic.
void DeletePendingOrders() { if((CLOSE_ORDER_PRICE_BUY && (Bid>=BUY_TAKE_PROFIT || Ask<=BUY_STOP_LOSS))) for(int i=OrdersTotal()-1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS)&&OrderSymbol()==_Symbol&&OrderType()==OP_SELLSTOP) if(!OrderDelete(OrderTicket())) Print("DeleteOrderError: ",GetLastError()); if((CLOSE_ORDER_PRICE_SELL && (Ask<=SELL_TAKE_PROFIT || Bid>=SELL_STOP_LOSS))) for(int i=OrdersTotal()-1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS)&&OrderSymbol()==_Symbol&&OrderType()==OP_BUYSTOP) if(!OrderDelete(OrderTicket())) Print("DeleteOrderError: ",GetLastError()); }
Here is your code simplified. It looks like you may have an issue with your upstream logic.
Thank you.....
But i get error.... do need to add return(0) at the end of it?
Thank you.....
But i get error.... do need to add return(0) at the end of it?
Which error.
It's a void so it don't return anything.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use