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

 

Hello,  is it possible to get the daily Profit in percent instead of the account Balance ?

any advice would be appreciated . 

in the attached screenshot you can see the code . 

best regards 

 
Audiamant:

Hello,  is it possible to get the daily Profit in percent instead of the account Balance ?

any advice would be appreciated . 

in the attached screenshot you can see the code . 

best regards 

Yes it it possible, 
1. Check current balance 
2. Check daily profit (both wins n losses) 
3. Subtract from current balance u get daily_initial balance 
4. Daily_Profit/daily_initial this gives is the fraction that if multiplied by 100 u get percentage 
 

hi guys , i have run 10 Experts, and get this error in all of them

How to fix this error ?


{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}

 
Mohammadreza Azarnia:

hi guys , i have run 10 Experts, and get this error in all of them

How to fix this error ?


{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}

Don't use 10 experts. Make all requests from the single EA.

 
Jefferson Metha:
Yes it it possible, 
1. Check current balance 
2. Check daily profit (both wins n losses) 
3. Subtract from current balance u get daily_initial balance 
4. Daily_Profit/daily_initial this gives is the fraction that if multiplied by 100 u get percentage 
Yeees Jeff you understand what I need LOL
 

Hi i have got error of 

2021.06.14 00:40:50.703 TelegramAlertMT4_MAsignal XNGUSD,M15: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

I have tested the token, channel name, chat id, all are working if i am using the http link, i.e https://api.telegram.org/botTOKEN/sendMessage?chat_id=1220568658&text=my%20sample%20text

What could go wrong please?

Of Course, I have also added webrequest in here, although i do have to say that the comment print out this error, but I dont see it in the experts message in the terminal.


 
luckyvictor:

Hi i have got error of 

2021.06.14 00:40:50.703 TelegramAlertMT4_MAsignal XNGUSD,M15: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

I have tested the token, channel name, chat id, all are working if i am using the http link, i.e https://api.telegram.org/botTOKEN/sendMessage?chat_id=1220568658&text=my%20sample%20text

What could go wrong please?

Of Course, I have also added webrequest in here, although i do have to say that the comment print out this error, but I dont see it in the experts message in the terminal.


Hi, I had the same problem as you.

copy this code and it will be ok.

find SendMessage function in Telegram.mqh, then paste the code below.

If you compare the code you will know what was the 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",_channel_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);
     }
 
Soroosh Davoodi:

Hi, I had the same problem as you.

copy this code and it will be ok.

find SendMessage function in Telegram.mqh, then paste the code below.

If you compare the code you will know what was the problem.

Please use Alt+S if u using a pc to post your code, or if in mobile shift to desktop site and select code tool and paste your code
 
Soroosh Davoodi:

Hi, I had the same problem as you.

copy this code and it will be ok.

find SendMessage function in Telegram.mqh, then paste the code below.

If you compare the code you will know what was the problem.

It does work! thanks very much, appreciated!

 
hello. 

How do I send a Screenshot to a Channel. 

I notice the SendMessage() function has 2 variants one that takes in ChannelName and one that takes in Chat ID. 

however the SendScreenshot () function takes in Chat ID only