
OrderClose - Trade Functions - MQL4 Reference
- docs.mql4.com
OrderClose - Trade Functions - MQL4 Reference
OrderClose(OrderTicket(),OrderLots(),Ask, 1, clrSilver);You can not use any Trade Functions unless you select an order first.
marek:
Hi there where is the mistake ? doesn't want to close the order :(
Thank you :)
int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { if(h4==-1 && h1==-1 && m30==-1 && m15==-1) { OrderSelect(i, SELECT_BY_POS); if (OrderSymbol()!=Symbol()) continue; int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE ); break; //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { if (GetLastError()>0) Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } } return(0);
corrected

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there where is the mistake ? doesn't want to close the order :(
Thank you :)