Product URL : https://www.mql5.com/en/market/product/164455
Documentation of Bybit API URL: https://bybit-exchange.github.io/docs/v5/information
Tutorial 1 : Buying and selling Operations
Script Demo :
Be aware : As soon as you bought the Library, It is going to be discovered beneath Scripts/Market Folder
#property copyright "Copyright 2026, Rajesh Kumar Nait" #property hyperlink "https://www.mql5.com/en/customers/rajeshnait/vendor" #property model "1.00" #property description "Uncomment code which is required" #embody <Customized/Crypto_Charting/JAson.mqh> CJAVal jv(NULL, jtUNDEF); struct BybitConfig { string api_url; string api_key; string api_secret; string api_suffix; string symbol_prefix; string class; string isLeverage; bool debug; }; #import "..LibrariesLibrary_Bybit_new.ex5" void Bybit_Init(BybitConfig &config); string GetTime(); string Get_exchangeInfo(); string orderLimit(string image, string facet, double amount, double value); string orderAmend(string image, string orderId, double qty, double value); string orderMarket(string image, string facet, double amount); string setTradingStop(string image, string slTrigger, string tpTrigger); string orderCancel(string image, string orderId); string orderCancelAll(string image); string orderRealtime( string image, string orderId, string openOnly); string orderHistory( string image, string orderId, string execType, string startTime, string endTime, string cursor); string tradeHistory( string image, string orderId, string orderStatus, string startTime, string endTime, string cursor); string getWalletBalance(string accountType); string setLeverage(string image, string buyLeverage, string sellLeverage); string getPositionMode(string image, string cursor); void CreateSymbols_Bybit(); void RunUpdate(string image, datetime StartDateTime); #import bool Bybit_debug = true; string Bybit_Key = "L51zfkjJZOCdF3ufip"; string Bybit_Secret = "txnyks6V3dkyhUWWY64l5ay02B0V6V5MNNZa"; string Bybit_URL = "https://api-testnet.bybit.com"; string Bybit_suffix = "/v5/"; string Bybit_SymbolPrefix = "bf_"; string class = "linear"; string isLeverage = "1"; datetime MaxDate= D'2026-2-1 00:00:00'; string sym; BybitConfig config; void OnStart() { config.api_url = Bybit_URL; config.api_key = Bybit_Key; config.api_secret = Bybit_Secret; config.api_suffix = Bybit_suffix; config.symbol_prefix = Bybit_SymbolPrefix; config.debug = Bybit_debug; config.class = class; config.isLeverage = isLeverage; Bybit_Init(config); orderMarket("BTCUSDT","Purchase",0.002); Sleep(10000); setTradingStop("BTCUSDT","60000.00","70000.00"); } string RemovePrefixFromSymbol() { sym = _Symbol; string prefix = "bf_"; int size = 2; string resultString; if(StringSubstr(sym, 0, size) == prefix) { resultString = StringSubstr(sym, size); return resultString; } else { resultString = sym; return NULL; } return NULL; }
FAQ
1. Find out how to take away image prefix from my image when sending order to binance? if image prefix is a_BTCUSDT, when sending order through API it’s best to ship “BTCUSDT” solely
right here is the script tutorial to take away prefix out of your image
void OnStart() { string sym = _Symbol; string prefix = "bf_"; int size = 3; string resultString; if (StringSubstr(sym, 0, size) == prefix) { resultString = StringSubstr(sym, size); } else { resultString = sym; } Print("Unique Image: ", sym); Print("End result String: ", resultString); }
2. How do i run chart to be up to date each few seconds through API?
Binance recommends to replace chart through Websocket which is accessible on product Crypto Charting as a result of API is just not for actual time chart and working it too regularly could lead to non permanent IP ban by Binance, however if you want to not use it and replace historical past through API
right here is how you are able to do it by including this in your EA.
#property copyright "Copyright 2024, MetaQuotes Ltd." #property hyperlink "https://www.mql5.com" #property model "1.00" int updatetime = 60; int OnInit() { EventSetTimer(1); return(INIT_SUCCEEDED); } void OnDeinit(const int cause) { EventKillTimer(); } void OnTimer() { whereas(!IsStopped()) { datetime now = TimeGMT(); static datetime UpdateTime = now; if(UpdateTime==now) { datetime mydate = iTime("bf_ETHUSDT",PERIOD_M1,2); RunUpdate("ETHUSDT", mydate); Print("Replace Carried out"); UpdateTime=now + updatetime; } } }