Ajuda com BOT Telegram

 

Boa tarde a todos, estou com uma certa dificuldade em fazer um bot pegar os pré alerta de um indicador para OB, e enviar para o telegram

o que eu fiz foi com base nas documentações do Voytenko, 

Esse arquivo aqui ele foi escrito pelo Wemerson C. , estou usando ele


#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);  

}

e chamo essa arquivo dentro do meu código como mostrado logo abaixo, porém, me retorna um erro de bad request 4xx, outros códigos que tenho como exemplo, apenas mandam entradas quando as mesmas são feitas no MQL4, e não o pré alerta de um indicador

e se deu win ou loss, alguém consegue me ajudar nesse sentido? com um exemplo ou o caminho por onde devo seguir.

Desde já agradeço a todos.

#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);
  }
 
fedeolindo:

Boa tarde a todos, estou com uma certa dificuldade em fazer um bot pegar os pré alerta de um indicador para OB, e enviar para o telegram

o que eu fiz foi com base nas documentações do Voytenko, 

Esse arquivo aqui ele foi escrito pelo Wemerson C. , estou usando ele


e chamo essa arquivo dentro do meu código como mostrado logo abaixo, porém, me retorna um erro de bad request 4xx, outros códigos que tenho como exemplo, apenas mandam entradas quando as mesmas são feitas no MQL4, e não o pré alerta de um indicador

e se deu win ou loss, alguém consegue me ajudar nesse sentido? com um exemplo ou o caminho por onde devo seguir.

Desde já agradeço a todos.

Em Opcoes, Expert tab, tem um checkbox permitir webrequest algo assim. Tem que colocar a api.telegram.org ali tambem. Se nao a chamada do webrequest sempre falha.

Razão: