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

 
Jefferson Metha #:

Top right corner there is a magnify glass icon also known as the search icon
left click it
then type 
" Binance"
Press [ENTER] Key on your desktop

then you will get them no need to scroll down. 

you welcome

Thanks, I located the library

 
HOW  getfile to BOT for user download file
 
telegram bot inputFile

How to write this

My English Is not good, sorry
thanks
 

Great article. It works. Can I ask you a nubian question. In indicators it says URL does not allowed for WebRequest

Do I understand correctly that WebRequest does not work in indicators ?

I figured it out. Synchronous pauses. It doesn't work. Too bad.


	          
 
Valeriy Yastremskiy WebRequest in indicators

Do I understand correctly that WebRequest does not work in indicators?

It doesn't work

 
Vitaly Muzichenko #:

It's not working

But it works in the tester)) SendNotification will have to. Not so convenient, and it doesn't work in the tester.

 

Help please, I'm confused. How to get programmatically id of your chat in a global variable knowing the token of your bot. It is clear that you can ask different bots about your id, but I want to programmatically.

There is a loop in the ProcessMessage function that gets the number I'm looking for, but it often returns zero, and I can't remember it.

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2022.02.10
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 
Another question. Knowing the token of the bot, is it possible to get the chat ID of the user who created this bot from Telegram without sending a message from the bot. We get the name of the bot by the token.
 
on mq5 side "chat.m_new_one.message_text"  gets the message that user sends to the bot directly which is great.
However can it be used to receive the message that is sent to the channel that the bot (the one which is communicating with the mt5 EA) is a member of ? 
 

Hello friends, I use the following code to send a message to Telegram. My problem is that instead of sending a message once, it sends several times.

please guide me.

#include <Telegram\TelegramL.mqh>


input string InpChannelName="";//Channel Name
input string InpToken="";//Bot Token


CCustomBot bot;

datetime time_signal=0;
//int SendMessage(const string channel_name,
                //const string text);




//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   time_signal=0;

//--- set token
   bot.Token(InpToken);


//--- done
   return(INIT_SUCCEEDED);
  }
 
  datetime _opened_last_time = TimeCurrent() ;
  datetime _closed_last_time = TimeCurrent()  ;
  
 

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)

{

}
     
  
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  

   string message = "";
   int total=OrdersTotal();
 
       
   for(int pos=0;pos<total;pos++){  // Current orders -----------------------
     if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
     if(OrderOpenTime() <= _opened_last_time) continue;
     
     message += StringFormat("Order opened!\r\nType: %s\r\nSymbol: %s\r\nPrice: %s\r\nSL: %s\r\nTP: %s\r\nTime: %s\r\nTicket:.%s ",
     order_type(),
     OrderSymbol(),
     DoubleToStr(OrderOpenPrice(),MarketInfo(OrderSymbol(),MODE_DIGITS)),
     DoubleToStr(OrderStopLoss(),MarketInfo(OrderSymbol(),MODE_DIGITS)),
     DoubleToStr(OrderTakeProfit(),MarketInfo(OrderSymbol(),MODE_DIGITS)),
     TimeToStr(OrderOpenTime(),TIME_MINUTES),
     IntegerToString(OrderTicket())
          
      );
    
     int res=bot.SendMessage(InpChannelName,message);
     if(res!=0)
         Print("Error: ",GetErrorDescription(res));
     
     }
  
      
  
      bool is_closed = false;

                   
  total = OrdersHistoryTotal();
      
   for(int pos=0;pos<total;pos++){  // History orders-----------------------
      if(OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)==false) continue;
      if(OrderCloseTime() <= _closed_last_time) continue;
     printf(OrderCloseTime());
     is_closed = true;
     
     message += StringFormat("Order closed!\r\nTicket: %s\r\nSymbol: %s\r\nClosing Price: %s\r\nTime: %s",
     IntegerToString(OrderTicket()),
     OrderSymbol(),
     DoubleToStr(OrderClosePrice(),MarketInfo(OrderSymbol(),MODE_DIGITS)),
     TimeToStr(OrderCloseTime(),TIME_MINUTES),
     DoubleToStr(order_pips(),1)
     
    
     );
      
      int res=bot.SendMessage(InpChannelName,message);
     if(res!=0)
         Print("Error: ",GetErrorDescription(res));
      
     }
 
   }
   
   
double order_pips() {
   double pips;
   
   if(OrderType() == OP_BUY) {
      pips =  (OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);
   } else {
      pips =  (OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT);
   }
   return pips/10;
}

string order_type_to_str(int type)
{
   return StringSubstr(EnumToString((ENUM_ORDER_TYPE)type), 11);
}
string order_type () {
   return order_type_to_str(OrderType());
   
   if(OrderType() == OP_BUY)        return "BUY";
   if(OrderType() == OP_SELL)       return "SELL";
   if(OrderType() == OP_BUYLIMIT)   return "BUY LIMIT";
   if(OrderType() == OP_SELLLIMIT)  return "SELL LIMIT";
   if(OrderType() == OP_BUYSTOP)    return "BUYSTOP";
   if(OrderType() == OP_SELLSTOP)   return "SELLSTOP";
   
   return "{err}";
}
   

   
//---