Sunday, February 23, 2025

Latest Posts

Binance EA Connection Library MT4 Documentation – Different – 17 March 2024


Product URL  : https://www.mql5.com/en/market/product/114646

This library will let you handle trades utilizing any of your EA and its very straightforward to combine on any EA which you are able to do your self with the script code which is talked about in description and in addition demo examples on video which reveals the entire course of which is for mt5 however works for mt4 with listed API calls avaialble for MT4.

– Place Restrict, SL Restrict and Take Revenue Restrict Orders

– Place Market, SL-Market, TP-Market orders

– Modify Restrict order

– Cancel Order

– Question Orders

– Change Leverage, margin

– Get Place data

and extra…

URL:

Spot:

  • For testnet API is : testnet.binance.imaginative and prescient
  • For LIVE MODE API is: api.binance.com
  • Futures:

  • For testnet API is testnet.binancefuture.com
  • For LIVE MODE API is: fapi.binance.com
  • Tutorial 1 : Buying and selling Operations, Please notice : Symbols creation or Historical past isn’t accessible in MT4 model

    Script Demo :

    
    
    
    
    
    #property copyright "Copyright 2024, Rajesh Kumar Nait"
    #property hyperlink      "https://www.mql5.com/en/customers/rajeshnait/vendor"
    #property model   "1.00"
    #property description "Uncomment code as required"
    
    
    struct BinanceConfig {
       string            api_url;
       string            api_key;
       string            api_secret;
       string            api_suffix;
       string            symbol_prefix;
       bool              debug;
    };
    
    
    #import "..LibrariesLibrary_Binance_mt4.ex5"
    void Binance_Init(BinanceConfig &config);
    string orderLimit(string image, string aspect, double amount, double worth, string timeInForce_, string recvWindow_,  string reduceOnly_);
    string modifyorderLimit(string image, lengthy oid, string aspect, double amount, double worth, string recWindow_,  string reduceOnly_);
    string orderMarket(string image, string aspect, double amount, string recWindow_,  string reduceOnly_);
    string orderStopMarket(string image,string aspect,double amount,double stopPrice, string workingtype, string recWindow_, string reduceOnly_, string priceProtect_ );
    string orderTakeProfitMarket(string image,string aspect,double amount,double stopPrice, string workingtype, string recWindow_,  string reduceOnly_, string priceProtect_ );
    string orderStopLimit(string image,string aspect,double amount,double stopPrice,double worth, string workingtype, string recWindow_, string reduceOnly_, string priceProtect_ );
    string orderTakeProfitLimit(string image,string aspect,double amount,double stopPrice,double worth, string workingtype, string recWindow_,  string reduceOnly_, string priceProtect_ );
    string CancelOrder(string image, lengthy orderId, string recWindow_ );
    string CancelAllOpenOrder(string image, string recWindow_ );
    string QueryPositionMode(string recWindow_ );
    string QueryMultiAssetMode(string recWindow_);
    string QueryOrderwithID(string image, lengthy orderid, string recWindow_);
    string CurrentOpenOrder(string image,lengthy orderid, string recWindow_);
    string CurrentAllOpenOrders(string image,string recWindow_);
    string GetFuturesBalance(string recWindow_);
    string GetAccount(string recWindow_);
    string changeLeverage(string image,int leverage, string recWindow_);
    string changeMargin(string image,string marginType, string recWindow_ );
    string positionRisk(string image, string recWindow_);
    #import
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bool   Binance_debug   = true;
    string Binance_Key     = ""; 
    string Binance_Secret  = ""; 
    string Binance_URL     = "https://testnet.binancefuture.com"; 
    string Binance_suffix  = "/fapi/v1/";
    string Binance_SymbolPrefix = "a_";
    
    
    
    
    
    string timeInForce="GTC";   
    string reduceOnly="true";   
    string priceProtect="true"; 
    string recvWindow="2000";   
    string working_Type = "CONTRACT_PRICE"; 
    
    
    
    
    
    datetime MaxDate= D'2023-12-20 00:00:00';
    
    
    BinanceConfig config;
    
    
    
    
    void OnStart() {
    
    
       config.api_url = Binance_URL;
       config.api_key = Binance_Key;
       config.api_secret = Binance_Secret;
       config.api_suffix = Binance_suffix;
       config.symbol_prefix = Binance_SymbolPrefix;
       config.debug = Binance_debug;
    
       Binance_Init(config);
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    FAQs :

    1. How you can take away image prefix from my image when sending order to binance? if image prefix is a_BTCUSDT, when sending order by way of API you must ship “BTCUSDT” solely

    right here is the script tutorial to take away prefix out of your image

    void OnStart() {
    
       string sym = _Symbol;
       string prefix = "bs_"; 
       int size = 3; 
       string resultString;
    
    
       if (StringSubstr(sym, 0, size) == prefix) {
          
          resultString = StringSubstr(sym, size);
       } else {
          
          resultString = sym;
       }
    
    
       Print("Unique Image: ", sym);
       Print("Consequence String: ", resultString);
    }

    2. I get fallacious Lot measurement calculation whereas calculating lot measurement for my EA, I take advantage of Google to calculate USD charges. What I’m doing fallacious?

    You need to calculate Lot measurement as per Binance guidelines solely. Listed here are hyperlinks to Binance Leveraged Margin Desk which mentions Upkeep Margin as per your place measurement. You need to deduct Upkeep margin out of your place measurement. Additionally you have to be occupied with Liquidation Calculation logic to be applied in your EA

    Instance : First go to Binance App and choose leverage you would like e.g. 125x

    then lets suppose your account stability is $33.69 and BTCUSDT worth is 59169.3

    then examine how a lot qty you should buy, on this case as per worth in screenshot you possibly can see I should purchase 0.071 max qty

    so be sure that your calculation is both 0.071 or beneath then your EA might be putting order with none concern.

    ——————————————————————————————

    5. How do i examine my USDT stability utilizing EA Connector library?

    Right here is the script demo

    
    
    
    
    
    #property copyright "Copyright 2024, MetaQuotes Ltd."
    #property hyperlink      "https://www.mql5.com"
    #property model   "1.00"
    
    #embrace <JAson.mqh>
    CJAVal jv_(NULL, jtUNDEF);
    
    
    struct BinanceConfig {
       string            api_url;
       string            api_key;
       string            api_secret;
       string            api_suffix;
       string            symbol_prefix;
       bool              debug;
    };
    
    
    #import "..LibrariesLibrary_Binance.ex5"
    void Binance_Init(BinanceConfig &config);
    string orderLimit(string image, string aspect, double amount, double worth, string timeInForce_, string recvWindow_,  string reduceOnly_);
    string modifyorderLimit(string image, lengthy oid, string aspect, double amount, double worth, string recWindow_,  string reduceOnly_);
    string orderMarket(string image, string aspect, double amount, string recWindow_,  string reduceOnly_);
    string orderStopMarket(string image,string aspect,double amount,double stopPrice, string workingtype, string recWindow_, string reduceOnly_, string priceProtect_);
    string orderTakeProfitMarket(string image,string aspect,double amount,double stopPrice, string workingtype, string recWindow_,  string reduceOnly_, string priceProtect_);
    string orderStopLimit(string image,string aspect,double amount,double stopPrice,double worth, string workingtype, string recWindow_, string reduceOnly_, string priceProtect_);
    string orderTakeProfitLimit(string image,string aspect,double amount,double stopPrice,double worth, string workingtype, string recWindow_,  string reduceOnly_, string priceProtect_);
    string CancelOrder(string image, lengthy orderId, string recWindow_);
    string CancelAllOpenOrder(string image, string recWindow_);
    string QueryPositionMode(string recWindow_);
    string QueryMultiAssetMode(string recWindow_);
    string QueryOrderwithID(string image, lengthy orderid, string recWindow_);
    string CurrentOpenOrder(string image,lengthy orderid, string recWindow_);
    string CurrentAllOpenOrders(string image,string recWindow_);
    string GetFuturesBalance(string recWindow_);
    string GetAccount(string recWindow_);
    string changeLeverage(string image,int leverage, string recWindow_);
    string changeMargin(string image,string marginType, string recWindow_);
    string positionRisk(string image, string recWindow_);
    #import
    
    bool Binance_debug     = true;
    
    
    string Binance_Key     = ""; 
    string Binance_Secret  = ""; 
    string Binance_URL     = "https://fapi.binance.com"; 
    
    
    string Binance_suffix  = "/fapi/v1/";
    string Binance_SymbolPrefix = "a_";
    
    
    
    
    string timeInForce="GTC";   
    string reduceOnly="true";   
    string priceProtect="true"; 
    string recvWindow="2000";   
    string working_Type = "CONTRACT_PRICE"; 
    
    
    BinanceConfig config;
    
    
    
    void OnStart() {
    
       config.api_url = Binance_URL;
       config.api_key = Binance_Key;
       config.api_secret = Binance_Secret;
       config.api_suffix = Binance_suffix;
       config.symbol_prefix = Binance_SymbolPrefix;
       config.debug = Binance_debug;
    
       Binance_Init(config);
    
    
       string s = GetFuturesBalance(recvWindow);
       jv_.Deserialize(s);
    
       for(int i=0; i<jv_.Measurement(); i++) {
    
          string asset = jv_[i]["asset"].ToStr();
          double bal = jv_[i]["balance"].ToDbl();
    
    
          if(asset=="USDT"){ 
             double stability = NormalizeDouble(bal,2);
             Print("Steadiness ",stability);
           }
       }
    
    }
    
    

    Latest Posts

    Don't Miss

    Stay in touch

    To be updated with all the latest news, offers and special announcements.