1015 / MQL5 / USDⓈ-M FUTURES
How can MQL5 change Binance USD-M futures leverage?
Call ufChangeInitialLeverage with a symbol and target leverage. On each tick, this example first requests 10× leverage and then 15× leverage for the chart symbol, parsing both responses. It changes account configuration rather than querying data or placing orders.
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.
- Use the intended contract symbol and appropriate trading permissions. Calls are sequential; determine the actual final leverage from successful responses and account configuration, not merely from the second requested value of 15.
How does the source execute?
- In OnTick, call ufChangeInitialLeverage(handles, Symbol(), 10, recvWindow, resultChar).
- Convert and parse the first response, then call again with leverage 15 and parse the second response.
- OnChartEvent handles ACCOUNT_CONFIG_UPDATE for event ID 3333.
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 | ufChangeInitialLeverage |
| Symbol | Symbol() |
| First requested leverage | 10 |
| Second requested leverage | 15 |
| Push event | ACCOUNT_CONFIG_UPDATE |
| 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. |