Discussão do artigo "Como criar bots para Telegram em MQL5" - página 46

 
Jefferson Metha #:

No canto superior direito, há um ícone de lupa, também conhecido como ícone de pesquisa
Clique com o botão esquerdo do mouse no ícone
e digite
" Binance"
Pressione a tecla [ENTER] em sua área de trabalho

e você terá acesso a eles, sem precisar rolar a tela para baixo.

Seja bem-vindo

Obrigado, localizei a biblioteca

 
HOW getfile to BOT for user download file
 
telegram bot inputFile

Como escrever isso

Meu inglês não é bom, desculpe, obrigado
 

Ótimo artigo. Ele funciona. Posso lhe fazer uma pergunta núbia? Nos indicadores, ele diz que o URL não é permitido para WebRequest

Entendi corretamente que o WebRequest não funciona nos indicadores ?

Já descobri o que é. Pausas síncronas. Não funcionam. É uma pena.


	          
 
Valeriy Yastremskiy WebRequest em indicadores

Entendi corretamente que o WebRequest não funciona em indicadores?

Ele não funciona

 
Vitaly Muzichenko #:

Não está funcionando

Mas funciona no testador)) SendNotification terá que ser usado. Não é tão conveniente e não funciona no testador.

 

Por favor, me ajude, estou confuso. Como obter programaticamente o ID do seu chat em uma variável global sabendo o token do seu bot. Está claro que você pode perguntar a diferentes bots sobre sua ID, mas eu quero fazer isso de forma programática.

Há um loop na função ProcessMessage que obtém o número que estou procurando, mas ele geralmente retorna zero e não consigo me lembrar dele.

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2022.02.10
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 
Outra pergunta. Sabendo o token do bot, é possível obter o ID do chat do usuário que criou esse bot no Telegram sem enviar uma mensagem do bot. Obtemos o nome do bot pelo token.
 
No lado do mq5, o "chat.m_new_one.message_text" recebe a mensagem que o usuário envia diretamente para o bot, o que é ótimo.
No entanto, ele pode ser usado para receber a mensagem que é enviada para o canal do qual o bot (aquele que está se comunicando com o EA do mt5) é membro?
 

Olá amigos, uso o código a seguir para enviar uma mensagem ao Telegram. Meu problema é que, em vez de enviar uma mensagem uma vez, ela é enviada várias vezes.

Por favor, me oriente.

#include <Telegram\TelegramL.mqh>


input string InpChannelName="";/Nome do canal
input string InpToken="";Token //Bot


CCustomBot bot;

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




//+------------------------------------------------------------------+
//| Função de inicialização especializada|
//+------------------------------------------------------------------+
int OnInit()
  {
   time_signal=0;

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


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

//+------------------------------------------------------------------+
//| Função de desinicialização de especialista|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)

{

}
     
  
//+------------------------------------------------------------------+
//| Função de tique de especialista|
//+------------------------------------------------------------------+
void OnTick()
  {
  

   string message = "";
   int total=OrdersTotal();
 
       
   for(int pos=0;pos<total;pos++){  // Pedidos atuais -----------------------
     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++){  // Pedidos de histórico-----------------------
      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}";
}
   

   
//---