The library is used to develop automatic trading on Binance Spot Market from MT5 platform.
1. Open MQL5 demo account
2. Download Header file and EA sample https://drive.google.com/uc?export=download&id=1kjUX7Hyy02EiwTLgVi8qdaCNvNzazjln
3. Allow WebRequest from MT5 Tools menu >> Options >> Expert Advisors and add URL:
https://testnet.binance.vision
4. Open any chart and attach BinanceEA-Sample to the chart
This function must be called from the OnInit() function
void init ( string symbol, // symbol name string historicalData, // historicalData: 1W = 1 week, 1M = 1 month, 3M = 3 months, 6M = 6 months, 1Y = 1 year string apiKey, // binance api key string secretKey, // binance secret key bool testnet = false // testnet mode );
This function must be called from the OnTimer() function
void getTickData();
This function must be called from the OnDeinit() function
void deinit(); The function used to place order, returns orderId if successful, otherwise -1
long order ( ORDERTYPE orderType, // enum ORDERTYPE: BUY_MARKET, SELL_MARKET, BUY_LIMIT, SELL_LIMIT, BUY_STOP, SELL_STOP, BUY_STOPLIMIT, SELL_STOPLIMIT double quantity, // order quantity double limitPrice = 0, // order limitPrice double stopPrice = 0, // order stopPrice string timeInForce = "GTC", // timeInForce: GTC, IOC, FOK, default GTC string comment = "" // order comment );
Cancel open orders, returns true if successful, otherwise false
bool cancelOrder ( long orderId = -1 // order Id, default -1 cancel all open orders );
Get the number of open orders
int ordersTotal ( ORDERTYPE orderType = -1 // enum ORDERTYPE: BUY_LIMIT, SELL_LIMIT, BUY_STOP, SELL_STOP, BUY_STOPLIMIT, SELL_STOPLIMIT, default -1 number of all open orders );
Get available asset balance
double getBalance ( string asset // asset name );
Get exchange info, returns ExchangeInfo structure if successful
void getExchangeInfo ( ExchangeInfo &exchangeInfo // [out] ExchangeInfo structure );
Get orderbook, returns OrderBook structure array if successful
void getOrderBook ( OrderBook &orderBook[], // [out] OrderBook structure array int limit = 5 // limit: 5, 10, 20, 50, 100, default 5 );
Get open orders, returns OpenOrders structure array if successful
void getOpenOrders ( OpenOrders &openOrders[] // [out] OpenOrders structure array );
Get trade history, returns TradeHistory structure array if successful
void getTradeHistory ( TradeHistory &tradeHistory[], // [out] tradeHistory structure array int limit = 10 // limit default 10, max 1000 );
#include <Binance.mqh>
input string Symbol = "BTCUSDC";
input string HistoricalData = "1W";
input string ApiKey = "";
input string SecretKey = "";
Binance b;
int OnInit()
{
b.init(Symbol,HistoricalData,ApiKey,SecretKey);
return 0;
}
void OnTimer()
{
b.getTickData();
}
void OnDeinit(const int reason)
{
b.deinit();
}
void OnTick()
{
// Place buy market order
// b.order(BUY_MARKET,0.001);
// Place buy limit order
// b.order(BUY_LIMIT,0.001,75000);
// Place buy stop order
// b.order(BUY_STOP,0.001,0,120000);
// Place buy stoplimit order
// b.order(BUY_STOPLIMIT,0.001,110000,120000);
// Place sell market order
// b.order(SELL_MARKET,0.001);
// Place sell limit order
// b.order(SELL_LIMIT,0.001,120000);
// Place sell stop order
// b.order(SELL_STOP,0.001,0,75000);
// Place sell stoplimit order
// b.order(SELL_STOPLIMIT,0.001,80000,75000);
// Cancel all open orders
// b.cancelOrder();
// Get available asset balance
// double balanceBTC = b.getBalance("BTC");
// double balanceUSDC = b.getBalance("USDC");
// Get the number of all open orders
// int ordTotal = b.ordersTotal();
/* // Get exchangeInfo
ExchangeInfo exchangeInfo;
b.getExchangeInfo(exchangeInfo);
string baseAsset = exchangeInfo.baseAsset;
string quoteAsset = exchangeInfo.quoteAsset;
double minQty = exchangeInfo.minQty;
double maxQty = exchangeInfo.maxQty;
double minNotional = exchangeInfo.minNotional;
int qtyDigit = exchangeInfo.qtyDigit;
int priceDigit = exchangeInfo.priceDigit;
*/
/* // Get orderBook
OrderBook orderBook[];
b.getOrderBook(orderBook);
for(int i = 0; i < ArraySize(orderBook); i++)
{
double askPrice = orderBook[i].askPrice;
double askQty = orderBook[i].askQty;
double bidPrice = orderBook[i].bidPrice;
double bidQty = orderBook[i].bidQty;
}
*/
/* // Get open orders
OpenOrders openOrders[];
b.getOpenOrders(openOrders);
for(int i = 0; i < ArraySize(openOrders); i++)
{
long orderId = openOrders[i].orderId;
string symbol = openOrders[i].symbol;
string side = openOrders[i].side;
string type = openOrders[i].type;
string status = openOrders[i].status;
string timeInForce = openOrders[i].timeInForce;
double price = openOrders[i].price;
double stopPrice = openOrders[i].stopPrice;
double origQty = openOrders[i].origQty;
double executedQty = openOrders[i].executedQty;
ulong time = openOrders[i].time;
}
*/
/* // Get trade history
TradeHistory tradeHistory[];
b.getTradeHistory(tradeHistory);
for(int i = 0; i < ArraySize(tradeHistory); i++)
{
long orderId = tradeHistory[i].orderId;
string symbol = tradeHistory[i].symbol;
double price = tradeHistory[i].price;
double qty = tradeHistory[i].qty;
double quoteQty = tradeHistory[i].quoteQty;
double commission = tradeHistory[i].commission;
string commissionAsset = tradeHistory[i].commissionAsset;
ulong time = tradeHistory[i].time;
bool isBuyer = tradeHistory[i].isBuyer;
bool isMaker = tradeHistory[i].isMaker;
}
*/
} If for any reason you do not like the purchased program, you can request a refund within 30 days from the date of purchase. You can also make an exchange for any other product at an equal cost or by paying the difference.
Simply send a request for refund or exchange with your order number by email: support@fx-market.pro.
Refund requests received more than 30 days after purchase will be rejected.