Why are you comparing constants? Order Properties - Trade Constants - Standard Constants, Enumerations and Structures - MQL4 Reference if( OP_BUYSTOP>0 ) { if( OP_BUY>0 )
You can only delete pending orders. When OrderType() > OP_SELL if( 4>0 ) // Always true { if( 0>0 ) // Never true.
if(!OrderSelect(i,SELECT_BY_POS, MODE_TRADES) == true) continue;
You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
Still does not work !!
mrgoodprice144:
Still does not work !!
Show what you have done
Still does not work !!
for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) { if(OP_BUY) { if(!OrderDelete(OrderTicket(),clrNONE)){ Print("Order Delete failed, order number: ",OrderTicket()," Error: ",GetLastError(), " On: ", OrderSymbol()); } else{ Print("Pending Order was deleted: ", OrderTicket(), " On: ", OrderSymbol()); } } if(!OrderSelect(i,SELECT_BY_POS, MODE_TRADES )) { if( OP_SELL) { if(!OrderDelete(OrderTicket(),clrNONE)){ Print("Order Delete failed, order number: ",OrderTicket()," Error: ",GetLastError(), " On: ", OrderSymbol()); } else{ Print("Pending Order was deleted: ", OrderTicket(), " On: ", OrderSymbol()); } } } } }Whys is it so comlicated to write a logical code i got 2 pending orders if one get hit the second one is deleted that 's it .
mrgoodprice144:
Whys is it so comlicated to write a logical code i got 2 pending orders if one get hit the second one is deleted that 's it .
Whys is it so comlicated to write a logical code i got 2 pending orders if one get hit the second one is deleted that 's it .
WHRoeder has already told you. Code like
if(OP_BUY)
Makes no sense
Maybe tou intend
if(OrderType()==OP_BUY)
but if it is a triggered buy, you cannot delete it, you can only close it. But again, you don't want to close the triggered buy, you want to delete the pending sell.
So make your code loop through the orders and if it finds a triggered buy, loop through the orders again and delete any pending orders that have been placed by the EA

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
I got this code that send 2 pending orders than i got an other code where u try to delete the one that did not got hit unstead my code his deleting both pending orders before they get hit
here is the code: