OrderDelete
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
Deleting Pending Orders
Trade requests for deleting of pending orders are formed using the function OrderDelete().
Function OrderDelete()
bool OrderDelete(int ticket, color arrow_color=CLR_NONE)
The function deletes the previously placed pending order. It returns TRUE, if it has worked successfully. Otherwise, it returns FALSE.
I guess what you are trying to do is to select an order from the History. You shall then use the MODE_HISTORY for your Order Select.
From the same Tutorial page : MODE_HISTORY - the order is selected in closed and deleted orders, i.e., among the orders displayed in the "Account History" tab of the "Terminal" window. In this case, the depth of history specified by the user for displaying of closed and deleted orders is important.
- book.mql4.com
OrderDelete
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
Deleting Pending Orders
Trade requests for deleting of pending orders are formed using the function OrderDelete().
Function OrderDelete()
bool OrderDelete(int ticket, color arrow_color=CLR_NONE)
The function deletes the previously placed pending order. It returns TRUE, if it has worked successfully. Otherwise, it returns FALSE.
I guess what you are trying to do is to select an order from the History. You shall then use the MODE_HISTORY for your Order Select.
From the same Tutorial page : MODE_HISTORY - the order is selected in closed and deleted orders, i.e., among the orders displayed in the "Account History" tab of the "Terminal" window. In this case, the depth of history specified by the user for displaying of closed and deleted orders is important.
if(!OrderDelete(OrderTicket(),Blue)) { ErrorDescription(GetLastError()); }
The code above means: if orderdelete == false then get the last error, but why does it execute the orderdelete if true (it should do nothing since i didnt say to do something if it was true), my code did not say (below)
if(OrderType()==OP_BUYLIMIT ||OrderType()==OP_SELLLIMIT ||
OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP)
{
OrderDelete(OrderTicket(),Blue);
}
I only mentioned in my code what to do if something is false, i never mentioned what it should do if something is true so in a true statement it should do nothing
The code above means: if orderdelete == false then get the last error, but why does it execute the orderdelete if true (it should do nothing since i didnt say to do something if it was true), my code did not say (below)
I only mentioned in my code what to do if something is false, i never mentioned what it should do if something is true so in a true statement it should do nothingif(!OrderDelete(OrderTicket(),Blue))
is the same as
if(OrderDelete(OrderTicket(),Blue)==false)
The function is executed in both cases. True/false checks the return value.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The code above executes orderdelete when there is a pending order type, although what i'm only trying to say is:
if it is not an order delete then get the last error, i did not state to execute orderdelete.
if(!OrderDelete(OrderTicket(),Blue))