void OrdersCloseLong(){ for(int i=0;i<PositionsTotal();i++){ if(PositionGetTicket(i)>0){ if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY&& PositionGetString(POSITION_SYMBOL)==_Symbol&&PositionGetInteger(POSITION_MAGIC)==MagicNumber){ if(!trade.PositionClose(_Symbol,ULONG_MAX)){ Print("OrderClose error ",GetLastError()); return; } else{i--;} } } } }
Order - pending orders.
Position - trading positions
In MQL5 it matters.
Ok, seems the code is good, but for some reason expert isn't still closing orders.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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,I have this orderclose function working in MQ4 but as the tester results doesnt show any closed position must be a translation mistake, if someone can check this issue I thank you in advance.