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 will likely be discovered underneath 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" #embrace 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 aspect, double amount, double value); string orderAmend(string image, string orderId, double qty, double value); string orderMarket(string image, string aspect, 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);
FAQ
1. 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 need 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("Outcome String: ", resultString); }
2. How do i run chart to be up to date each few seconds by way of API?
Binance recommends to replace chart by way of Websocket which is obtainable on product Crypto Charting as a result of API shouldn’t be for actual time chart and operating it too steadily might end in non permanent IP ban by Binance, however if you want to not use it and replace historical past by way of 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 Finished"); UpdateTime=now + updatetime; } } }