Why is this working?

 
if(OrderType()==OP_BUYLIMIT ||OrderType()==OP_SELLLIMIT ||
   OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP)
   {
   if(!OrderDelete(OrderTicket(),Blue))
   ErrorDescription(GetLastError());
   }

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))
 

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.


Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
  • book.mql4.com
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
 
Hamza Boukraa:

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
 
Renz Carillo:

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 nothing
if(!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.

 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:

is the same as

The function is executed in both cases. True/false checks the return value.

I get it now, thank you!