Discussion of article "How to create bots for Telegram in MQL5" - page 6

 

This Telegram lib was not work with Indicators, work with EA only.

Anyone can tell me how to send the message from Indicator (not EA) to Telegram?

Thank.

 

Hello everyone, I'm using telegram.mqh on MT4 without any compilation errors.

Is it possible to works as an indicator?

 
Cuong Le Van:

This Telegram lib was not work with Indicators, work with EA only.

Anyone can tell me how to send the message from Indicator (not EA) to Telegram?

Thank.

Use telegram4mql dll

 
Emanuel Canuto:

Hello everyone, I'm using telegram.mqh on MT4 without any compilation errors.

Is it possible to works as an indicator?

Use telegram4mql dll

 

I tried this code in OnInit() to send a message to my channel. but it does not work, can you give me example on how to send message to a channel or group chat?

thanks

bot.SendMessage("t.me/BotSignals","Hello",false,false);

 
Cuong Le Van:

This Telegram lib was not work with Indicators, work with EA only.

Anyone can tell me how to send the message from Indicator (not EA) to Telegram?

Thank.

There is an difference, Expert can access websites, but Indicator nearly can't. Then we should push telegram SendMessage to Expert

Thank you very much, Sir Andrey Voytenko

 
Andrey Voytenko:

ok. But if you are working with a private channel, use the Channel ID, not the Channel Name.

Hello Andrey


your library for mt5 seems cannot work under Asynchronous MODE with telegram


when mt5 bot  send two message at the same seconds , one of the mesages will be lost .


I tested many times . could you look into this issue ?

 

Hi andrey


Thank you very much first of all for your time and for your article has helped me a lot and I have read all the publications.

Reading between them I have finally been able to work with the "Telegram_Bot_EA" in to MT5.

Trying "Telegram_Signal_EA" in to MT5, I have not managed to send any signal with either "MA" or "MACD" or with a custom indicator.

The compilation works well but does not send an alert or message.However I know that it is well configured since I have been able to work with "Telegram_Bot_EA".

I have reviewed the code both the EA and the telegram.mqh I do not see where the fault may be and I am stuck.The EA( Telegram_Signal_EA) cant be send any text info.

Could you help me?Its same files that original article.

In this forum i see this code but i think its not my problem:

   //+------------------------------------------------------------------+
   int SendMessage(const string _channel_name,
                   const string _text,
                   const bool   _as_HTML=false,
                   const bool   _silently=false)
     {
      //--- check token
      if(m_token==NULL)
         return(ERR_TOKEN_ISEMPTY);

      string name=StringTrim(_channel_name);
      if(StringGetCharacter(name,0)!='@')
         name="@"+name;

      string out;
      string url=StringFormat("%s/bot%s/sendMessage",TELEGRAM_BASE_URL,m_token);
      string params=StringFormat("chat_id=%s&text=%s",name,UrlEncode(_text));
      if(_as_HTML)
         params+="&parse_mode=HTML";
      if(_silently)
         params+="&disable_notification=true";
      //      Print(params);
      int res=PostRequest(out,url,params,WEB_TIMEOUT);
      return(res);
     }

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


 Note:I´m sure that work because "Telegram_Bot_EA" can be run well.


Another one: 

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_KEYDOWN && 
      lparam=='Q')
     {
         
         bot.SendMessage(InpChannelName,"ee\nAt:100\nDDDD");
     }
  }

Note:i press "Q" in to bot chat or channel chat and dont work....i think if you press the key,bot send you text...right?Well, this option cant work.I dont understand... I dont have any error´s or warnings to compile all mql5 code.


Resume: i like send to telegram text signal(buy/sell) about your example indicators or my custom indicators rules but i dont understant why not work me.


Thank you and nice day.


UPDATE1(solved):


I check logs and get this info:

HL 0 06:24:00.729 Telegram_Signal_EAEVO (DE30,M1) Error: Bad Request

LH 0 06:40:00.916 Telegram_Signal_EAEVO (DE30,M1) {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

RG 0 06:40:00.916 Telegram_Signal_EAEVO (DE30,M1) Error: Bad Request

KQ 0 07:31:00.442 Telegram_Signal_EAEVO (DE30,M1) {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

MO 0 07:31:00.442 Telegram_Signal_EAEVO (DE30,M1) Error: Bad Request

I´m add a new father and resolve the last error,  but again cant be send message the bot...

EF    0    12:26:44.372    Telegram_Signal_EAEVO (DE30,H1) NAME_bot: NAMEsignalsbot 


UPDATE2(solved):

I check this link http://usefulmix.com/send-message-telegram-channel-bot-http-api/


In the text :


So we need to make the channel private, however in doing so our above HTTP API call will stop working and this is what trying to prublish a message will look like:


{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: chat not found"
}

i check with the url sample and get this:

        
ok      false
error_code      404
description     "Not Found"


In common.mqh list this error but i´m very lost with this....I research more.

The "problem" its with a convert token, i write and type this code to test and the bot write me:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//Original code:

// {
// 
//  if(id==CHARTEVENT_KEYDOWN &&   lparam=="Q")
//bot.SendMessage(InpChannelName,"ee\nAt:100\nDDDD");
//}

//Test code:

 {

  
   if(id==CHARTEVENT_KEYDOWN && 
      lparam=="Q")
   
      //--- set token
   bot.Token(InpToken);
    bot.SendMessage("ID CHAT OR USER","ITS A TEST!");

}
     

Image:

I read again the general post because one people talk about this.


TO UPDATE 3!:

How to send a message to a Telegram channel using the HTTP bot sendMessage API
How to send a message to a Telegram channel using the HTTP bot sendMessage API
  • 2018.10.08
  • admin
  • usefulmix.com
Here’s a practical example how to send a message to a Telegram channel using a Telegram Bot and the HTTP bot sendMessage API. In order to be able to do so, you will have to the following: Create a Telegram public channel (we’ll make this private later) Create a Telegram BOT via BotFather Set the bot as administrator in your channel After...
 

Hello make sure to import telegram.mqh and see here : 

https://www.mql5.com/en/forum/285054/page2#comment_11220261

MT4 to Telegram
MT4 to Telegram
  • 2019.04.04
  • www.mql5.com
Can anyone code or have any idea how to send trade details from MT4 to a Telegram channel. This is the sort of thing I am talking about. Thanks...
 
Marco vd Heijden:

Hola, asegúrese de importar telegram.mqh y vea aquí: 

https://www.mql5.com/en/forum/285054/page2#comment_11220261

I check...i need take time...later i write you.Thanks!!!!!
Reason: