Cancel open orders when price invalidates trade.
Should I amend the code something like..
It is better you run and see what happens. Never asks unless it would not run like it should.
However, what I see here is more to logic solutions rather than problems.
brad:I placed orders to open short on the NZDUSD daily TF. for(int i=OrdersTotal();OrdersTotal()>0;i--) { DeleteOrder=OrderDelete(TicketArray[i-1]); |
|
Thanks for your assistance.
I placed orders to open short on the NZDUSD daily TF.
The entry was just below the bar low and I wanted my code to close the orders if price invalidated the trade by moving above the bar high.
It appeared that my code closed the orders before price moved above the bar high.
Below is a screen shot of where I think the orders were closed.
The red horizontal line shows the invalidation level.
The orange arrow shows the bar that price almost touched but didn't on the 15 min chart until later.
My code closed the orders at this time and I had to reopen the positions again which were soon closed again.
Here is some code:.
Did this happen because of the spread?
Should I amend the code something like..
Thanks,
Brad.