Send alert signal to telegram

 
How to send alert signal from metatrader4 to telegram channel

See file attach please

Help me please

Files:
 
How to create bots for Telegram in MQL5
How to create bots for Telegram in MQL5
  • www.mql5.com
During the F8 conference held in San Francisco on 12th of April in 2016, Facebook announced the integration of API for bots into the Messenger. The same day a major update for the Telegram Bot Platform was released. Version 2.0 has pleasantly surprised with its functionality. It seems that bots that used to be popular in the ICQ era are now...
 

This example How send message from indicator to Telegram

#property link      "https://www.mql5.com"

#property version   "1.00"
#property strict
#property indicator_chart_window

#include <Wininet.mqh>
#define telegramBaseURL   "https://api.telegram.org"

///https://tlgrm.ru/docs/bots/api почитать как что отправлять
input string inpToken="111111111:gdfgsdfgsdfgsSDASffasd f";//Token
input string inpChat_id ="-346546546546456456";
bool inpParsMode =true;

int OnInit()
  {
    string data;
    string url="https://api.telegram.org/bot" + inpToken + "/sendMessage?chat_id="+inpChat_id;
   
    if(inpParsMode){
      url = url + "&parse_mode=HTML";
    } 
   
    url = url + "&text= " + "<b>1114</b>";
    
    ReadUrl(url,data);

    return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }

//+------------------------------------------------------------------+


thi library win

//+------------------------------------------------------------------+

//|                                                      Wininet.mqh |

//|                                                     Version: 1.0 |

//|                            Copyright 2015, Wemerson C. Guimaraes |

//|                  https://www.mql5.com/pt/users/wemersonrv/seller |

//|                  ;     |

//+------------------------------------------------------------------+

#property copyright "Copyright 2015, Wemerson C. Guimaraes"

#property link      "https://www.mql5.com/pt/users/wemersonrv/seller"

//=================================================================================================

//=================================================================================================

//====================================   ReadUrl Function   =======================================

//=================================================================================================

//=================================================================================================

#define READURL_BUFFER_SIZEX   100

#define HTTP_QUERY_STATUS_CODE  19


#import  "Wininet.dll"

   int InternetOpenW(string, int, string, string, int);

   int InternetConnectW(int, string, int, string, string, int, int, int); 

   int HttpOpenRequestW(int, string, string, int, string, int, string, int); 

   int InternetOpenUrlW(int, string, string, int, int, int);

   int InternetReadFile(int, uchar & arr[], int, int& OneInt[]);

   int InternetCloseHandle(int); 

   int HttpQueryInfoW(int ,int ,uchar &lpvBuffer[],int& lpdwBufferLength, int& lpdwIndex);

#import



void ReadUrl(string url, string& data)

{

int HttpOpen = InternetOpenW(" ", 0, " ", " ", 0); 

   int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1); 

   int HttpRequest = InternetOpenUrlW(HttpOpen, url, NULL, 0, 0, 0);

   

   uchar cBuff[5];

   int cBuffLength=10;

   int cBuffIndex=0;

   int HttpQueryInfoW = HttpQueryInfoW(HttpRequest, HTTP_QUERY_STATUS_CODE, cBuff, cBuffLength, cBuffIndex);

   

   // HTTP Codes... Only the 1st character (4xx, 5xx, etc)

   int http_code = (int) CharArrayToString(cBuff, 0, WHOLE_ARRAY, CP_UTF8);   

   if( http_code==4 || http_code==5 ){ // 4XX || 5XX

      Print("HTTP Error: ", http_code, "XX");

      if (HttpRequest > 0) InternetCloseHandle(HttpRequest); 

      if (HttpConnect > 0) InternetCloseHandle(HttpConnect); 

      if (HttpOpen > 0) InternetCloseHandle(HttpOpen);  

      data="HTTP_ERROR";

   }else{

      int read[1];

      uchar  Buffer[];

      ArrayResize(Buffer, READURL_BUFFER_SIZEX + 1);

      data="";

      while (true)

      {

         InternetReadFile(HttpRequest, Buffer, READURL_BUFFER_SIZEX, read);

         string strThisRead = CharArrayToString(Buffer, 0, read[0], CP_UTF8);

         if (read[0] > 0)

            data = data + strThisRead;

         else

            break;

      }

   }

   

   if (HttpRequest > 0) InternetCloseHandle(HttpRequest); 

   if (HttpConnect > 0) InternetCloseHandle(HttpConnect); 

   if (HttpOpen > 0) InternetCloseHandle(HttpOpen);  

}


Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • www.mql5.com
Каждый день на витрине MQL5 Маркета появляются десятки новых приложений для автоматизации торговли. Выберите подходящее среди 10 000 продуктов и избавьтесь от ненужных рутинных операций. Продавайте свои программы для алготрейдинга в нашем Маркете — в самом большом магазине торговых приложений для трейдеров! One Click Close Скрипт помогает легко...