Delete Order

 

Hi,

Why if i run the script it doesn't work?

it says : Error 4109. Is something with with the code?


/+------------------------------------------------------------------+
//| delete_pending.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link ""
#property show_confirm

double Slip;
bool result;
int start()
{

//----

//----

for (int f = 0; f < OrdersTotal(); f++)
{
OrderSelect(f,SELECT_BY_POS, MODE_TRADES);
switch (OrderType())
{
case OP_BUY : result = OrderClose(OrderTicket(), OrderLots(), Bid, 3);
case OP_SELL : result = OrderClose(OrderTicket(), OrderLots(), Ask, 3);

case OP_BUYLIMIT : result = OrderDelete(OrderTicket());
case OP_BUYSTOP : result = OrderDelete(OrderTicket());
case OP_SELLLIMIT : result = OrderDelete(OrderTicket());
case OP_SELLSTOP : result = OrderDelete(OrderTicket());

}
}

if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
//----
return(0);
}
//+------------------------------------------------------------------+

Files:
Error.gif  92 kb
 

Error 4109 is ERR_TRADE_NOT_ALLOWED according to Expert Advisor MetaTrader Error Codes which is a site you may need to bookmark

As to why, I do not know sorry.

Reason: