Discusión sobre el artículo "Cómo crear un bot para Telegram en el lenguaje MQL5" - página 7

 

Hola Andrey,

¿por qué el bot sigue recibiendo Error: Solicitud HTTP fallida, tq

 

Hola Andrey,

¿por qué el bot sigue recibiendo Error: Solicitud HTTP fallida, tq


 

Puede que hayan cambiado el protocolo.

Has comprobado la API de Telegram?

 
Haijie Qi:

Hola Andrey,

¿por qué el bot sigue recibiendo Error: HTTP request failed, tq

He depurado el 'Telegram_Bot_EA' en tu PC usando TeamViewer y he encontrado que WebRequest() devolvió -1. _LastError = 5203.

Pero no sé por qué. Quizás tu firewall bloquea los paquetes TCP.

 
Andrey Voytenko:

He depurado el 'Telegram_Bot_EA' en tu PC usando TeamViewer y he encontrado que WebRequest() devuelve -1. _LastError = 5203.

Pero no sé por qué. Quizás tu cortafuegos bloquea los paquetes TCP.


Gracias Andrey,

desactivar el firewall todavía error,

Voy a mirar más profundo :)

 

Hola chicos, así que básicamente he tomado el código fuente y básicamente editado el código para el telegram_signal_EA para enviar operaciones basadas en mi estrategia. Así que he compilado para comprobar si hay errores y todo funciona bien, incluso cuando aplico la EA a la tabla de la ficha expertos muestra que su reconocido mi bot telegrama. Ahora mi problema radica en el envío de la alerta en sí, no estoy recibiendo alertas a telegrama cuando mis reglas para un comercio se cumplen. Cualquier ayuda en este chicos? Aquí está el código de abajo

//+------------------------------------------------------------------+
//|Telegram_Signal_EA.mq5
//| Copyright 2014, MetaQuotes Software Corp. |
//|http://www.mql5.com
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict

#include <Telegram.mqh>

//--- parámetros de entrada
input string InpChannelName="ForexSignalChannel";//Nombre del canal
input string InpToken="";/Token

//--- variables globales
CCustomBot bot;
int ema_handle;
int ema2_handle;
int rsi_handle;
datetime time_signal=0;
bool checked;
//+------------------------------------------------------------------+
//| Función de inicialización experta|
//+------------------------------------------------------------------+
int OnInit()
  {
   time_signal=0;

   bot.Token(InpToken);

#ifdef __MQL5__   
   ema_handle=iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,0);
   if(ema_handle==INVALID_HANDLE)
      return(INIT_FAILED);
      
   ema2_handle=iMA(NULL,0,400,0,MODE_EMA,PRICE_CLOSE,0);
   if(ema2_handle==INVALID_HANDLE)
      return(INIT_FAILED);
      
   rsi_handle=iRSI(NULL,0, 14,PRICE_CLOSE,0);
   if(ema2_handle==INVALID_HANDLE)
      return(INIT_FAILED);
//--- añadir el indicador al gráfico
   int total=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);
   ChartIndicatorAdd(0,total,macd_handle);
#endif   

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Función de desinicialización experta|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(reason==REASON_PARAMETERS ||
      reason==REASON_RECOMPILE ||
      reason==REASON_ACCOUNT)
     {
      checked=false;
     }

//--- borrar el indicador
#ifdef __MQL5__ 
   int total=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);
   for(int subwin=total-1; subwin>=0; subwin--)
     {
      int amount=ChartIndicatorsTotal(0,subwin);
      for(int i=amount-1; i>=0; i--)
        {
         string name=ChartIndicatorName(0,subwin,i);
         if(StringFind(name,"MACD",0)==0)
            ChartIndicatorDelete(0,subwin,name);
        }
     }
#endif
  }
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
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");
     }
  }
//+------------------------------------------------------------------+
//| Función tick experto|
//+------------------------------------------------------------------+
void OnTick()
  {

   if(!checked)
     {
      if(StringLen(InpChannelName)==0)
        {
         Print("Error: Channel name is empty");
         Sleep(10000);
         return;
        }

      int result=bot.GetMe();
      if(result==0)
        {
         Print("Bot name: ",bot.Name());
         checked=true;
        }
      else
        {
         Print("Error: ",GetErrorDescription(result));
         Sleep(10000);
         return;
        }
     }

//--- obtener tiempo
   datetime time[1];
   if(CopyTime(NULL,0,0,1,time)!=1)
      return;

//--- comprueba la señal en cada barra
   if(time_signal!=time[0])
     {
      //--- primer calculo
      if(time_signal==0)
        {
         time_signal=time[0];
         return;
        }

     double ema = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, 0);
      double ema2 = iMA(NULL, 0, 400, 0, MODE_EMA, PRICE_CLOSE, 0); 
      double rsi = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);


      time_signal=time[0];

      //--- Enviar señal BUY
      if ((Bid > ema)&&(Bid < ema2)&&(rsi < 30))
      
        {
         string msg=StringFormat("Name: BossPips Signal\xF4E3\nSymbol: %s\nTimeframe: %s\nType: Buy\nPrice: %s\nTime: %s",
                                 _Symbol,
                                 StringSubstr(EnumToString((ENUM_TIMEFRAMES)_Period),7),
                                 DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits),
                                 TimeToString(time[0]));
         int res=bot.SendMessage(InpChannelName,msg);
         if(res!=0)
            Print("Error: ",GetErrorDescription(res));
        }

      //--- Enviar señal VENTA
      
       if ((Bid < ema)&&(Bid > ema2)&&(rsi > 70))
       
        {
         string msg=StringFormat("Name: BossPips Signal\xF4E3\nSymbol: %s\nTimeframe: %s\nType: Sell\nPrice: %s\nTime: %s",
                                 _Symbol,
                                 StringSubstr(EnumToString((ENUM_TIMEFRAMES)_Period),7),
                                 DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits),
                                 TimeToString(time[0]));
         int res=bot.SendMessage(InpChannelName,msg);
         if(res!=0)
            Print("Error: ",GetErrorDescription(res));
        }
     }
  }
//+------------------------------------------------------------------+
 
¿Alguna versión para mq4?
 
Mohd Fahmi Azlan Mohamad Zuki:
¿Alguna versión para mq4?

Los códigos adjuntos a este artículo están adaptados para operar en ambas plataformas - MetaTrader 4 y MetaTrader 5.

Sólo tienes que cambiar las extensiones de archivo EAs a mq4.

 

cambio de for(int i=0;i<=1;i++) a for(int i=0;i>=1;i--) en señal ea,

ahora no tengo señal de telegram, puede ayudarme/guiarme ;(

 
Andrey Voytenko:

Los códigos adjuntos a este artículo están adaptados para operar en ambas plataformas - MetaTrader 4 y MetaTrader 5.

Sólo tienes que cambiar las extensiones de archivo EAs a mq4.

He intentado cambiar .. Pero cuando pongo orden, im no recibir ninguna notificación. ¿Algo que tengo que comprobar?