How do I automatically cancel an unfilled pending stop order before the strategy places another trade?
Assuming you mean in code, use the OrderSend function to issue a removal/deletion of the order in question. before placing the new order.
Delete the pending order placed previously
![Documentation on MQL5: Trade Functions / OrderSend Documentation on MQL5: Trade Functions / OrderSend](https://c.mql5.com/36/59/documentation-on-mql5-trade-functions__3.png)
- www.mql5.com
Then unfortunately it is difficult for us to tell you where to put the code.
One would assume that if you already coded an EA that places orders, then you should already be familiar with how OrderSend works, and that you would simply execute the "remove" just before you place the new order using the same OrderSend function but with different request parameters.
Also, since you posted in the MQL5 section, my answer is relevant to MQL5 code. If however, your code is MQL4, then please let us know because MQL4 trade functions are completely different to MQL5.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a stop limit order strategy I would like to program a way to automatically cancel an unfilled pending order placed by the strategy before it places a new order.
So automatically cancel the pending order at the open of the next bar for example OR if the price of the current bar (0) breaks above or below a certain price level (the high or low of a previous bar for example).