The current documentation is created for the library available via the following link in the Market: https://www.mql5.com/en/market/product/74587. The script with examples of use of the mentioned functions is attached in the bottom of the current page.
Main information
Function | Response examples |
---|---|
long GetBinanceFuturesServerTimestamp() - returns the current UNIX timestamp of Binance Futures server. | 1650907985201 |
long GetBinanceSpotServerTimestamp(bool binanceUs = false) - returns the current UNIX timestamp of Binance Spot server. Parameters: binanceUs - reflects if the Binance.com or Binance.US server will be used | 1650915784657 |
string CreateOrUpdateSymbol(string symbol, int digitsNumber, string postfix, string marketType, bool binanceUs = false) - creates or updates specification of the instrument that should be added in the Symbols list of the MetaTrader 5. symbol - instrument name that will be added to Symbols list digitsNumber - precision of the instrument postfix - specific add-on to the instrument name to make it unique (e.g. ".bins" to create 'BTCUSDT.bins' symbol on Spot Market) marketType - desired name for Market that the instrument will be added to in the Symbols binanceUs - should be set to True if the Library will be uses to access Binance.US exchange instead of Binance.com | BTCUSDT.bins added successfully |
string GetFuturesExchangeInfo(pair_specification_struct & futures_specs[]) - fill the struct that is passed via reference to the function with the specifications of all futures instruments from Binance. The function itself returns empty string if the download was successful or a description of an error if it occurred. NOTE: the Ask and Bid parameters are filled via GetFuturesPriceTicker() function. | futures_specs[n].symbol: "BTCUSDT" futures_specs[n].price_precision: 2 futures_specs[n].volume_precision: 4 futures_specs[n].ask_price: 0 futures_specs[n].bid_price: 0 futures_specs[n].time: 1650981628134 |
string GetSpotExchangeInfo(pair_specification_struct & spot_specs[], bool BinanceUS) - fill the struct that is passed via reference to the function with the specifications of all spot instruments from Binance. The function itself returns empty string if the download was successful or a description of an error if it occurred. NOTE: the Ask and Bid parameters are filled via GetSpotPriceTicker() function. Parameters: BinanceUS - reflects if the Binance.com or Binance.US server will be used | spot_specs[n].symbol: "ETHUSDT" spot_specs[n].price_precision: 2 spot_specs[n].volume_precision: 3 spot_specs[n].ask_price: 0 spot_specs[n].bid_price: 0 spot_specs[n].time: 1651121628134 |
string GetCoinmFuturesExchangeInfo(pair_specification_struct & coinm_futures_specs[]) - fill the struct that is passed via reference to the function with the specifications of all COIN-M futures from Binance. The function itself returns empty string if the download was successful or a description of an error if it occurred. NOTE: the Ask and Bid parameters are filled via GetCoinmFuturesPriceTicker() function. | coinm_futures_specs[n].symbol: "ETHUSDT" coinm_futures_specs[n].price_precision: 2 coinm_futures_specs[n].volume_precision: 3 coinm_futures_specs[n].ask_price: 0 coinm_futures_specs[n].bid_price: 0 coinm_futures_specs[n].time: 1651121628134 |
string GetFuturesPriceTicker(int offsetHours, pair_specification_struct & futures_specs[]) - fill the current Ask, Bid and Time parameters for all the futures instruments from BinanceParameters: offsetHours - set the desired offset in hours from Binance server time | futures_specs[n].symbol: "BTCUSDT" futures_specs[n].price_precision: 0 futures_specs[n].volume_precision: 0 futures_specs[n].ask_price: 38123.84 futures_specs[n].bid_price: 38122.54 futures_specs[n].time: 1650981628134 |
string GetFuturesPriceTicker(string symbol, int offsetHours, pair_specification_struct & futures_specs[]) - fill the current Ask, Bid and Time parameters for all the futures instruments from BinanceParameters: symbol - specify the instrument to get the Ask, Bid and Time for | futures_specs[n].symbol: "BTCUSDT" futures_specs[n].price_precision: 0 futures_specs[n].volume_precision: 0 futures_specs[n].ask_price: 38123.84 futures_specs[n].bid_price: 38122.54 futures_specs[n].time: 1650981628134 |
string GetSpotPriceTicker(int offsetHours, pair_specification_struct & futures_specs[]) - fill the current Ask, Bid and Time parameters for all the spot instruments from BinanceParameters: offsetHours - set the desired offset in hours from Binance server time | spot_specs [n].symbol: "BTCUSDT" spot_specs [n].price_precision: 0 spot_specs [n].volume_precision: 0 spot_specs [n].ask_price: 38123.84 spot_specs [n].bid_price: 38122.54 spot_specs [n].time: 1650981628134 |
string GetSpotPriceTicker(string symbol, int offsetHours, pair_specification_struct & futures_specs[]) - fill the current Ask, Bid and Time parameters for all the futures spot from BinanceParameters: symbol - specify the instrument to get the Ask, Bid and Time for | spot_specs [n].symbol: "BTCUSDT" spot_specs [n].price_precision: 0 spot_specs [n].volume_precision: 0 spot_specs [n].ask_price: 38123.84 spot_specs [n].bid_price: 38122.54 spot_specs [n].time: 1650981628134 |
string GetCoinmFuturesPriceTicker(int offsetHours, pair_specification_struct & coinm_futures_specs[]) - fill the current Ask, Bid and Time parameters for all the COIN-M futures instruments from BinanceParameters: offsetHours - set the desired offset in hours from Binance server time | coinm_futures_specs[n].symbol: "BTCUSDT" coinm_futures_specs[n].price_precision: 0 coinm_futures_specs[n].volume_precision: 0 coinm_futures_specs[n].ask_price: 38123.84 coinm_futures_specs[n].bid_price: 38122.54 coinm_futures_specs[n].time: 1651121628134 |
string GetCoinmPriceTicker(string symbol, int offsetHours, pair_specification_struct & coinm_futures_specs[]) - fill the current Ask, Bid and Time parameters for all the COIN-M futures from BinanceParameters: symbol - specify the instrument to get the Ask, Bid and Time for | coinm_futures_specs[n].symbol: "BTCUSDT" coinm_futures_specs[n].price_precision: 0 coinm_futures_specs[n].volume_precision: 0 coinm_futures_specs[n].ask_price: 38123.84 coinm_futures_specs[n].bid_price: 38122.54 coinm_futures_specs[n].time: 1651121628134 |
Historical Data
Function | Response examples |
---|---|
string SpotLoadLastBar(string symbol, string postfix, ENUM_TIMEFRAMES period, int offsetHours, bool binanceUs = true) - fill the OHLCV of the current candle on the specified timeframe for the selected instrument. NOTE: It's recommended to use PERIOD_M1 setting for period because MetaTrader 5 will construct higher timeframes from it. | |
string FuturesLoadLastBar(string symbol, string postfix, ENUM_TIMEFRAMES period, int offsetHours) - fill the OHLCV of the current candle on the specified timeframe for the selected instrument. NOTE: It's recommended to use PERIOD_M1 setting for period because MetaTrader 5 will construct higher timeframes from it. | |
string CoinmFuturesLoadLastBar(string symbol, string postfix, ENUM_TIMEFRAMES period, int offsetHours) - fill the OHLCV of the current candle on the specified timeframe for the selected instrument.NOTE: It's recommended to use PERIOD_M1 setting for period because MetaTrader 5 will construct higher timeframes from it. | |
string SpotLoadData(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours, bool binanceUs = false) - fill the OHLCV data for the defined period of days for specified instrument Parameters: symbol - specify the instrument to get the data for | |
string FuturesLoadData(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours) - fill the OHLCV data for the defined period of days for specified futures instrument Parameters: symbol - specify the instrument to get the data for | |
string CoinmFuturesLoadData(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours) - fill the OHLCV data for the defined period of days for specified COIN-M futures instrument Parameters: symbol - specify the instrument to get the data for | |
string SpotLoadDataPostexist(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours, bool binanceUs = false) - fill the OHLCV data for the defined period of days from the last available date in MetaTrader 5 for specified spot instrument Parameters: symbol - specify the instrument to get the data for | |
string FuturesLoadDataPostexist(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours) - fill the OHLCV data for the defined period of days from the last available date in MetaTrader 5 for specified futures instrument Parameters: symbol - specify the instrument to get the data for | |
string CoinmFuturesLoadDataPostexist(string symbol, string postfix, ENUM_TIMEFRAMES period, int daysToLoad, int offsetHours) - fill the OHLCV data for the defined period of days from the last available date in MetaTrader 5 for specified COIN-M futures instrument Parameters: symbol - specify the instrument to get the data for |
Account
Function | Response example |
---|---|
string GetSpotBalances(string apikey, string secretkey, balances & balanceCurrencies[], bool BinanceUS) - get the balances for each currency wallet on the spot accountParameters: apikey - specify the Binance API key | balanceCurrencies[n].symbol: "BTC" balanceCurrencies[n].amount: 1.4354 |
string GetFuturesBalances(string apikey, string secretkey, balances & balanceCurrencies[]) - get the balances for each currency wallet on the futures account Parameters: apikey - specify the Binance API key | balanceCurrencies[n].symbol: "ETH balanceCurrencies[n].amount: 5.4543 |
string GetCoinmFuturesBalances(string apikey, string secretkey, balances & balanceCurrencies[]) - get the balances for each currency wallet on the COIN-M futures accountParameters: apikey - specify the Binance API key | balanceCurrencies[n].symbol: "ETH balanceCurrencies[n].amount: 5.4543 |
string GetSpotOrders(string apikey, string secretkey, string symbol, orders_struct & ordersArray[], bool BinanceUS) - get the opened orders on the specified spot instrumentParameters: apikey - specify the Binance API key | ordersArray[n].symbol: "BTCUSDT" ordersArray[n].orderId: "dsf88f23jf8328" ordersArray[n].price: 43323.49 ordersArray[n].size: 0.5 ordersArray[n].type: "Limit" ordersArray[n].side: "Buy" ordersArray[n].stopprice: 0 |
string GetFuturesOrders(string apikey, string secretkey, string symbol, orders_struct & ordersArray[]) - get the opened orders on the specified futures instrumentParameters: apikey - specify the Binance API key | ordersArray[n].symbol: "BTCUSDT" ordersArray[n].orderId: "dsf88f23jf8328" ordersArray[n].price: 43323.49 ordersArray[n].size: 0.5 ordersArray[n].type: "Limit" ordersArray[n].side: "Buy" ordersArray[n].stopprice: 0 |
string GetCoinmFuturesOrders(string apikey, string secretkey, string symbol, orders_struct & ordersArray[]) - get the opened orders on the specified COIN-M futures instrumentParameters: apikey - specify the Binance API key | ordersArray[n].symbol: "BTCUSDT" ordersArray[n].orderId: "dsf88f23jf8328" ordersArray[n].price: 43323.49 ordersArray[n].size: 0.5 ordersArray[n].type: "Limit" ordersArray[n].side: "Buy" ordersArray[n].stopprice: 0 |
string GetFuturesPositions(string apikey, string secretkey, string symbol, positions_struct & positionsArray[]) - get the opened positions on the specified futures instrumentParameters: apikey - specify the Binance API key | positionsArray [n].symbol: "BTCUSDT" positionsArray [n].side: "Buy" positionsArray [n].price: 43323.49 positionsArray [n].size: 0.5 |
string GetCoinmFuturesPositions(string apikey, string secretkey, string symbol, positions_struct & positionsArray[]) - get the opened positions on the specified COIN-M futures instrumentParameters: apikey - specify the Binance API key | positionsArray [n].symbol: "BTCUSDT" positionsArray [n].side: "Buy" positionsArray [n].price: 43323.49 positionsArray [n].size: 0.5 |
string SendSpotOrderToBinance(string symbol = "", string direction = "", string type = "", double lot = 0, double entry_price = 0, double stop_price = 0,string apikey = "", string secretkey = "", bool binanceUs = false) - send the order for the specified spot instrumentParameters: symbol - specify the instrument direction - specify if the direction is either "BUY" or "SELL" type - specify if the order type is one of the following: "MARKET", "LIMIT" or "STOP_LOSS_LIMIT" lot - specify the amount to enter entry_price - specify the price for pending (LIMIT or STOP_LOSS_LIMIT) orders. For MARKET orders it must be empty stop_price - specify the stop price if it is a STOP_LOSS_LIMIT order. For other order types it must be empty apikey - specify the Binance API key secretkey - specify the Binance Secret key BinanceUS - reflects if the Binance.com or Binance.US server will be used | "SELL LIMIT order on ETHUSDT successfully executed" |
string SendFuturesOrderToBinance(string symbol = "", string direction = "", string type = "", double lot = 0, double entry_price = 0, double stop_price = 0, double stop_loss = 0, double take_profit = 0, string apikey = "", string secretkey = "") - send the order for the specified futures instrumentParameters: symbol - specify the instrument direction - specify if the direction is either "BUY" or "SELL" type - specify if the order type is one of the following: "MARKET", "LIMIT" or "STOP_LOSS_LIMIT" lot - specify the amount to enter entry_price - specify the price for pending (LIMIT or STOP_LOSS_LIMIT) orders. For MARKET and STOP_MARKET orders it must be empty stop_price - specify the stop price if it is a STOP_LOSS_LIMIT or STOP_MARKET order. For other order types it must be empty stop_loss - specify the stop-loss price take_profit - specify the take-profit price apikey - specify the Binance API key secretkey - specify the Binance Secret key | "BUY LIMIT order on BTCUSDT successfully executed" |
string SendCoinmFuturesOrderToBinance(string symbol = "", string direction = "", string type = "", double lot = 0, double entry_price = 0, double stop_price = 0, double stop_loss = 0, double take_profit = 0, string apikey = "", string secretkey = "") - send the order for the specified COIN-M futures instrumentParameters: symbol - specify the instrument direction - specify if the direction is either "BUY" or "SELL" type - specify if the order type is one of the following: "MARKET", "LIMIT" or "STOP_LOSS_LIMIT" lot - specify the amount to enter entry_price - specify the price for pending (LIMIT or STOP_LOSS_LIMIT) orders. For MARKET and STOP_MARKET orders it must be empty stop_price - specify the stop price if it is a STOP_LOSS_LIMIT or STOP_MARKET order. For other order types it must be empty stop_loss - specify the stop-loss price take_profit - specify the take-profit price apikey - specify the Binance API key secretkey - specify the Binance Secret key | "BUY LIMIT order on XRPUSDT successfully executed" |
string CancelSpotOrderToBinance(string symbol = "", long orderId = 0, string apikey = "", string secretkey = "", bool binanceUs = false) - cancel the order on the specified spot instrumentParameters: symbol - specify the instrument orderId - specify if the orderId of the order that has to be cancelled apikey - specify the Binance API key secretkey - specify the Binance Secret key binanceUS - reflects if the Binance.com or Binance.US server will be used | "BUY LIMIT order on XRPUSDT successfully cancelled" |
string CancelFuturesOrderToBinance(string symbol = "", long orderId = 0, string apikey = "", string secretkey = "") - cancel the order on the specified futures instrumentParameters: symbol - specify the instrument orderId - specify if the orderId of the order that has to be cancelled apikey - specify the Binance API key secretkey - specify the Binance Secret key | "SELL LIMIT order on ETHUSDT successfully cancelled" |
string CancelCoinmFuturesOrderToBinance(string symbol = "", long orderId = 0, string apikey = "", string secretkey = "") - cancel the order on the specified COIN-M futures instrumentParameters: symbol - specify the instrument orderId - specify if the orderId of the order that has to be cancelled apikey - specify the Binance API key secretkey - specify the Binance Secret key | "SELL LIMIT order on ADAUSDT successfully cancelled" |