1009 / MQL5 / USDⓈ-M FUTURES
How can MQL5 set a countdown to cancel Binance open orders?
Use ufAutoCancelAllOpenOrders to configure a cancel-all countdown for a symbol. This example uses the chart symbol and countdownTime=60000 milliseconds, then reads symbol and countdownTime from the response. Each tick sends the configuration request again.
What do you need to use this example?
- Install and configure MT5 Binance and API credentials. Make mt5binance.mqh, JAson.mqh and the account permissions required by this example available.
- Choose the symbol and countdown appropriate to your order management. The countdown applies to all open orders on that symbol, not just this EA. Repeatedly resetting it is not equivalent to a guaranteed cancellation exactly 60 seconds after attachment.
How does the source execute?
- On every OnTick, call ufAutoCancelAllOpenOrders with symbol, 60000 and recvWindow.
- Convert and deserialize the UTF-8 response; read symbol and countdownTime in the code==0 branch.
- Print the response on the error branch. Although isRun is declared, OnTick does not use it to prevent repeated configuration.
Requests run on every OnTick without an effective one-shot guard. Frequency follows ticks received by the chart.
Parameters and execution behavior
| Parameter | Source value or behavior |
|---|---|
| Main interface | ufAutoCancelAllOpenOrders |
| Symbol | Symbol() |
| Countdown | 60000 ms |
| Response fields | symbol / countdownTime |
| Request timing window | recvWindow = 3000 ms |
| Execution trigger | Requests run on every OnTick without an effective one-shot guard. Frequency follows ticks received by the chart. |