//+------------------------------------------------------------------+ //| BitcoinView_Ver1.00.mq4 | //| Dr.EA Keiji | //| https://www.dr-ea.com/meta-blog/ | //+------------------------------------------------------------------+ #property copyright "Dr.EA Keiji" #property link "https://www.dr-ea.com/meta-blog/" #property version "1.00" #property strict #define check_interval 5 #define brokers_cnt 3 string url[brokers_cnt] = { "https://coincheck.com", "https://public.bitbank.cc", "https://api.zaif.jp" }; enum broker { Coincheck, bitbank, Zaif }; string broker_name[brokers_cnt] = { "Coincheck", "bitbank", "Zaif" }; double bid[][brokers_cnt]; double ask[][brokers_cnt]; double bid_size[][brokers_cnt]; double ask_size[][brokers_cnt]; int price_get_cnt = 5; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- ArrayResize(bid, price_get_cnt); ArrayResize(ask, price_get_cnt); ArrayResize(bid_size, price_get_cnt); ArrayResize(ask_size, price_get_cnt); OnTimer(); EventSetTimer(check_interval); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- EventKillTimer(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ void OnTimer() { uint tick_start = GetTickCount(); int i; bool res_bool; string result_str, url_path; // Coincheck url_path = "/api/order_books"; res_bool = API_GET(url[Coincheck] + url_path, result_str); if(res_bool == false) { Print("Coincheck API error."); } res_bool = SetCoincheckPriceToArray(result_str); if(res_bool == false) { Print("Coincheck Depth is too small."); } // bitbank url_path = "/btc_jpy/depth"; res_bool = API_GET(url[bitbank] + url_path, result_str); if(res_bool == false) { Print("bitbank API error."); } res_bool = SetBitbankPriceToArray(result_str); if(res_bool == false) { Print("bitbank Depth is too small."); } // Zaif url_path = "/api/1/depth/btc_jpy"; res_bool = API_GET(url[Zaif] + url_path, result_str); if(res_bool == false) { Print("Zaif API error."); } res_bool = SetZaifPriceToArray(result_str); if(res_bool == false) { Print("Zaif Depth is too small."); } string text_cmt = ""; text_cmt = text_cmt + "BTC / JPY\n"; text_cmt = text_cmt + broker_name[0] + " || "; text_cmt = text_cmt + broker_name[1] + " || "; text_cmt = text_cmt + broker_name[2]; int cmt_price_cnt = 5; for(i=cmt_price_cnt-1; i>=0; i--) { text_cmt = text_cmt + "\n"; text_cmt = text_cmt + DoubleToStr(ask[i][Coincheck], 0) + ", " + DoubleToStr(ask_size[i][Coincheck], 4); text_cmt = text_cmt + " || "; text_cmt = text_cmt + DoubleToStr(ask[i][bitbank], 0) + ", " + DoubleToStr(ask_size[i][bitbank], 4); text_cmt = text_cmt + " || "; text_cmt = text_cmt + DoubleToStr(ask[i][Zaif], 0) + ", " + DoubleToStr(ask_size[i][Zaif], 4); } text_cmt = text_cmt + " Ask\n"; for(i=0; i