Why OrderDelete() failed?

 

Now, I pend one buy limit order using my demo account. But, when I run the following EA, It do not work.

GetLastError() returns 133.

Which friend can help me? Thank you very much in advance!

int start() //
{
int Orders=OrdersTotal(); //
for(int i =0; i<Orders; i++)
{
Alert("Order id=", i,",Symbol", OrderSymbol());
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OP_BUYLIMIT == OrderType())
{
Alert("Buy limit order");
if(true == OrderDelete(OrderTicket(), CLR_NONE))
{
Alert("Order:", OrderTicket()," delete success.");
}
else
{
Alert("Order:", OrderTicket()," delete failed.");
}
}
}
}
Alert("Error num:", GetLastError());
return (0); //
}

 
if (OrderType() == OP_BUYLIMIT)
if(OrderDelete(OrderTicket(), CLR_NONE)== true)

error 133 =
ERR_TRADE_DISABLED 133 Trade is disabled.
 
qjol:
error 133 =
ERR_TRADE_DISABLED 133 Trade is disabled.

I just want to test the function OrderDelete().
 
jian770921:

I just want to test the function OrderDelete().


no probleb but pay attention of the rules of writing code

 

Thank you and another question:

Now, an buy limit order which was created by hand. I want to ask if the OrderDelete() function can delete this hand-created order?

 
jian770921:

Thank you and another question:

Now, an buy limit order which was created by hand. I want to ask if the OrderDelete() function can delete this hand-created order?


Add one point: this is just a pending order.
 
jian770921:

Thank you and another question:

Now, an buy limit order which was created by hand. I want to ask if the OrderDelete() function can delete this hand-created order?


yes
 

Yes – you can delete manual trades – just use 0 as magic number when you go in a loop to find this trade. And as mentioned above – you need to have autotrading activated and trading cannot be disabled – even for pending trades.

 
Marzena Maria Szmit #:

Yes – you can delete manual trades – just use 0 as magic number when you go in a loop to find this trade. And as mentioned above – you need to have autotrading activated and trading cannot be disabled – even for pending trades.

The OP does not filter by magic number in the code so your comment is irrelevant.

Why are you replying to a 12 year old topic? Especially as the OP's account has been deleted!