Download MetaTrader 5

(Solved) OrderClose problem

To add comments, please log in or register
GrumpyDuckMan
338
GrumpyDuckMan  

Hello everyone,

I don't really understand order 1 and order 3 error messages.

  void CloseTicket()
  {
// 0= order 61204533 /NZDJPY     / Market is closed
// 1= order 61204413 /oil-oct17  / Invalid price
// 2= order 61202214 /USDHKD     / Market is closed
// 3= order 61176067 /usdx-sep17 / Invalid trade volume
   if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)
   TicketNumber=OrderTicket();// 
     
   bool Order_Closing=OrderClose(TicketNumber,LOT,Ask,SLIPPAGE,clrNONE);
   Alert("Closing Order failed ",GetLastError());
 }

 and this, why is USDX-sep17 removed?

(solved) I was looking at the wrong log file, I was looking in MQL4 logs

0       18:00:02.651    ForumTest USDX-SEP17,H1: Alert: Closing Order failed 132
0       18:00:02.651    ForumTest USDX-SEP17,H1: initialized
0       18:00:12.172    ForumTest USDX-SEP17,H1: uninit reason 4
0       18:00:12.371    Expert ForumTest USDX-SEP17,H1: removed
GrumpyDuckMan
338
GrumpyDuckMan  

I think I have got the code working now.

void CloseTicket()
  {
   if(OrderSelect(0,SELECT_BY_POS)==true)
   
   bool Order_Closing=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),SLIPPAGE,clrNONE);
   
   Alert("Closing Order failed ",GetLastError());
}
whroeder1
15934
whroeder1  
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
GrumpyDuckMan
338
GrumpyDuckMan  
whroeder1:
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)

Thank you, whroeder1

I don't really understand the importance of magic numbers, due to the fact I have never tried them yet (To do next).

I haven't really tried using OrdersTotal.  I have been trying to use OrderType.

GrumpyDuckMan
338
GrumpyDuckMan  
Swap = OrderSwap();

This one has me completely confused at the moment. I don't know how it is calculated on currently open orders.

To add comments, please log in or register