1021 / MQL5 / USDⓈ-M FUTURES
How can MQL5 paginate Binance account income history?
Use ufGetIncomeHistory with page, limit and a time range to paginate income records. This example queries from 2025-05-01 to 2025-07-01 22:59:59 with 1,000 records per page, stopping the current pagination loop when fewer than 1,000 records are returned.
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.
- Replace the fixed dates with your intended range. The code multiplies StringToTime results by 1,000 and performs no additional timezone conversion. Availability remains subject to endpoint rules; the sample dates are not guaranteed to remain queryable.
How does the source execute?
- On every tick, reset startTime, endTime, page=1, limit=1000 and returnRows=limit.
- While returnRows==limit, query the next page with empty symbol and incomeType filters.
- Parse the response, increment page, update returnRows from the array size and traverse incomeType, income, asset, time, tranId and tradeId.
Each OnTick restarts from page 1. The current loop stops when fewer than limit records are returned.
Parameters and execution behavior
| Parameter | Source value or behavior |
|---|---|
| Main interface | ufGetIncomeHistory |
| Start | 2025-05-01 00:00:00 |
| End | 2025-07-01 22:59:59 |
| Symbol and type filters | Empty strings |
| Initial page | 1 |
| Page size | 1000 |
| Continue condition | returnRows == limit |
| Request timing window | recvWindow = 3000 ms |
| Execution trigger | Each OnTick restarts from page 1. The current loop stops when fewer than limit records are returned. |