Hi Dan,
One possibility comes to mind. This logic will only work if you have exactly one order open (for your whole account - not just this EA). If you have any other open orders then this won't work. You might try changing that logic to if(totalO>=1). Also, not sure if it matters or not but your loop that looks at opened orders counts one too many times. You might try changing that logic to something like this: for(i=0; i<OrdersTotal(); i++). This is because the order positions count from zero to OrdersTotal() - 1.
Good Luck,
Tovan
Hi Dan,
One possibility comes to mind. This logic will only work if you have exactly one order open (for your whole account - not just this EA). If you have any other open orders then this won't work. You might try changing that logic to if(totalO>=1). Also, not sure if it matters or not but your loop that looks at opened orders counts one too many times. You might try changing that logic to something like this: for(i=0; i<OrdersTotal(); i++). This is because the order positions count from zero to OrdersTotal() - 1.
Good Luck,
Tovan
Tovan,
Thanks for the thoughts.....I can see how the logic may need to be changed, but the funny thing is I have this same exact loop on another EA and it works like a charm! I cannot figure out why it won't remove limit orders. Now on the other EA, it is removing stop orders. That is pretty much the only real difference I can see in the code. This one really has me baffled. In any case, I will attempt the change as you suggest and see if I can get that to work. I did change the condition and tried the following: if(totalO>0), if(totalO!=0) still nothing! Dan
Tovan,
Thanks for the thoughts.....I can see how the logic may need to be changed, but the funny thing is I have this same exact loop on another EA and it works like a charm! I cannot figure out why it won't remove limit orders. Now on the other EA, it is removing stop orders. That is pretty much the only real difference I can see in the code. This one really has me baffled. In any case, I will attempt the change as you suggest and see if I can get that to work. I did change the condition and tried the following: if(totalO>0), if(totalO!=0) still nothing! Dan
Ok, I got it figure out.....was running strategy tester with an older version of the EA! Go figure....keeping track of all these files in a task in and of itself! D
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can anyone elaborate as to why my EA will not delete Limit orders yet on another EA that is written almost identically, it will remove the stop orders? Is there something I am missing here!? Both trades detailed below get placed with no problem, but once the sell or buy are closed, it is almost like it is never getting into the removal function! Any help would be greatly appreciated!! Dan
int totalO = OrdersTotal();
if(totalO==0)
{
if(Ask >= UB)
{
OrderSend(Symbol(),OP_SELL,lot,Bid,3,0,Bid-12*Point,NULL,0,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,lot,Bid+50*Point,3,0,Bid+20*Point,NULL,0,0,Red);
}
if(Bid <= LB)
{
OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,Ask+12*Point,NULL,0,0,Green);
OrderSend(Symbol(),OP_BUYLIMIT,lot,Ask-50*Point,3,0,Ask-20*Point,NULL,0,0,Green);
}
}
else
{
if(totalO==1)
removal();
}
//----
return(0);
}
void removal()
{
int i;
for(i=OrdersTotal(); i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket());
if(OrderSymbol()==Symbol() && OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
}
}