Binance API timing and security
Understand recvWindow to manage request timing and API security.
About request timing
Network conditions vary, so latency between your program and Binance servers can fluctuate. This is why we configure recvWindow . For high-frequency trading with stricter timing requirements, adjust recvWindow to suit your needs.
Recommendation — A recvWindow of less than 5,000 milliseconds is recommended. A smaller window tightens timing validation. For high-frequency scenarios, a 1,000ms or 500ms window provides stricter validation.
How recvWindow works
Binance checks each request timestamp against server time and the permitted recvWindow. Requests outside the allowed window are rejected, limiting the validity period of a signed request.
recvWindow in the MQL API
The Binance MQL API functions in this software accept a recvWindow parameter. Typical examples are shown below:
// 获取现货账户信息
void spAccountInformation(int &handles[], long recvWindow, char &result[]);
// 查询U本位合约订单
void ufQueryOrder(int &handles[], string symbol, long orderId,
string origClientOrderId, long recvWindow, char &result[]);
// 创建限价单示例(含recvWindow)
void ufNewOrder(int &handles[], string symbol, string side,
string type, string quantity, string price,
long recvWindow, char &result[]);
The trading, account query, order placement and cancellation interfaces include recvWindow so developers can control request timing.
High-frequency trading
Consider recvWindow = 1000–2000ms with local NTP synchronization and a clock offset below 100ms to support timely execution.
General strategies
A recvWindow of 5000ms allows for network variation and is a practical starting point for many intraday and swing strategies.
Clock synchronization
Enable automatic NTP synchronization on the server running MQL and keep its clock within one second of standard time.
Error handling
If you receive error -1021 (Timestamp for this request is outside of the recvWindow), check clock synchronization or adjust recvWindow.
Further technical details
For full details of Binance API timing security, refer to the official documentation:
The official documentation explains timing validation, error codes and implementation guidance. Review it when developing your integration.
MT5 + MQL API support the recvWindow parameter
Customize recvWindow in your API calls to balance request timing requirements with network conditions.
← Back to MT5 Binance