I'm wanting to delete 3 orders and replace them if the below is true... I'm doing something wrong though as it is not deleting all 3 open pending orders and replacing them all with new "NewBuyOrder"... Can anyone help? Thanks!
- can you partially close a pending order
- deleting all pending if found one working order
- Can't get this code to delete a pending order..
DomGilberto:
I'm wanting to delete 3 orders and replace them if the below is true... I'm doing something wrong though as it is not deleting all 3 open pending orders and replacing them all with new "NewBuyOrder"... Can anyone help? Thanks!
Take the OrderSend() out of the loop . . . adding in new orders is, I think, confusing the situation. Remember what you need to do inside the loop, then do it outside the loop.
I'm wanting to delete 3 orders and replace them if the below is true... I'm doing something wrong though as it is not deleting all 3 open pending orders and replacing them all with new "NewBuyOrder"... Can anyone help? Thanks!
Thanks RaptorUK.
Hmmm... Hasn't done the trick. I'm placing Prints all over the place to figure it out with no luck so far. As I have 3 pending orders, will the above code (from what you can see) cut it in terms of deleting all 3 open orders?
for(PositionIndex1 = TotalNumberOfOrders1 - 1; PositionIndex1 >= 0 ; PositionIndex1 --) // <-- for loop to loop through all Orders . . COUNT DOWN TO ZERO ! { if( ! OrderSelect(PositionIndex1, SELECT_BY_POS, MODE_TRADES) ) continue; // <-- if the OrderSelect fails advance the loop to the next PositionIndex if( OrderMagicNumber() == MagicNumber1 && MagicNumber2 && MagicNumber3 // <-- does the Order's Magic Number match our EA's magic number ? && OrderSymbol() == Symbol() // <-- does the Order's Symbol match the Symbol our EA is working on ? && ( OrderType() == OP_BUYSTOP ) ) { if(BuyStopPrice - OrderStopLoss() > Point / 2. ) { Stored_BuyPrice = OrderOpenPrice(); DeleteOrder = OrderDelete(OrderTicket()); if(DeleteOrder != TRUE) Print("Buy Delete Order Failed = ",GetLastError(), " On: ", OrderSymbol()); if(DeleteOrder==True)Print("Buy Order Deleted = ", OrderTicket(), " On: ", OrderSymbol()); }
is this line correct?
if( OrderMagicNumber() == MagicNumber1 && MagicNumber2 && MagicNumber3
as it looks to me as if it was saying:if( OrderMagicNumber() == MagicNumber1) if( MagicNumber2) if( MagicNumber3)
which are true/false, true, true
while you may want to say:
if( OrderMagicNumber() == MagicNumber1 || OrderMagicNumber()== MagicNumber2 || OrderMagicNumber()== MagicNumber3 )
dunno if that's what's happening, hope this helps
update: this has done something! Will report back in a minute.
if( OrderMagicNumber() == MagicNumber1 || OrderMagicNumber()== MagicNumber2 || OrderMagicNumber()== MagicNumber3 )
That's sorted it Xavilin - thank you very much for your help and time!!!
DomGilberto:
That's sorted it Xavilin - thank you very much for your help and time!!!
That's sorted it Xavilin - thank you very much for your help and time!!!
you're welcome, you can't imagine how amateur i am :D

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