For sure you can't delete OP_SELL or OP_BUY orders which are not pending orders.
oh I thought I was telling the EA that if ticket1 is now a Sell order rather than a sellstop then delete the buystop. Is that not the case?
Jowin6789:
oh I thought I was telling the EA that if ticket1 is now a Sell order rather than a sellstop then delete the buystop. Is that not the case?
Ah sorry, read too fast. Yes this logic should work however your code has a lot of issues.
- You don't need a loop if you select by ticket.
- You need to check the returned value by the functions (OrderSelect(), OrderDelete())
- Are you sure your variable ticket1/ticket2 are correct ?
- If the code is like that (OrderChecking/Deleting) just after placing an order, your pending will never be triggered.
Print the values, debug your code to find what is happening, what error code is returned.
Change this line
OrderSelect(ticket1,SELECT_BY_TICKET);
to
if(OrderSelect(i,SELECT_POS)==true)
{
..delete ticket
}
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
Hi All,
Been trying to get this code to delete a pending order. Basically I'm trying to set two pending orders, one buystop and one sellstop, and when one executes i want to close the other one. Trying to do it by naming them ticket1 and ticket2 as below but its not deleting any:
Can anyone spot something wrong or suggest a better/easier way of doing this?
Thanks for any help it would be much appreciated!!!
Jowin