Discusión sobre el artículo "Cómo crear un bot para Telegram en el lenguaje MQL5" - página 52
Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
No había código cuando respondí , veo que se puede reemplazar el bot.SendMessage con una función que añade el mensaje a una lista de ráfaga . También podrías seguir creciendo el mensaje y enviarlo fuera del bucle pero ahí chocarías con limitaciones de caracteres.
Un breve esquema podría ser así :
Gracias por contestar, lo intentaré a tu manera.
¡Hola!
Por ejemplo, para la fuente en negrita necesitas habilitar el envío HTML en Telegram.mqh.
Y luego enviar el texto en la etiqueta <b>.
No importa....
Encontré la respuesta poniendo la bandera AsHTML a true...
bot.SendMessage(InpTelegramId,"<b>Balance: $10056.21</b>",true);
Lo siento...
Hola, ¿puedes compartir el código de cómo hacer eso? También estoy buscando el código para hacer que el texto en negrita y en cursiva estilo y enviar al servidor de telegramas.
.
Roman, si necesitas el bot solo para enviar capturas de pantalla, puedes hacerlo de esta manera:
1. Pide al @MyTelegramID_bot tu número de chat.
2. Escribe un bot sencillo que compruebe si hay novedades y envíe imágenes al chat con el ID especificado. Un ejemplo es:
//+------------------------------------------------------------------+
//| Parámetros de entrada|
//+------------------------------------------------------------------+
input ENUM_LANGUAGES InpLanguage=LANGUAGE_EN;//Idioma
input string InpToken="";/Token
input long ChatId=0; //Chat ID
//---
CCustomBot bot;
int pos_count;
//+------------------------------------------------------------------+
int OnInit()
{
bot.Token(InpToken);
int res=bot.GetMe();
if(res!=0)
{
Print(GetErrorDescription(res));
}
pos_count=PositionCount(_Symbol);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnTick()
{
int pos_count_new=PositionCount(_Symbol);
if(pos_count_new>pos_count)
{
pos_count=pos_count_new;
int result=SendScreenShot(ChatId,_Symbol,0,NULL);
if(result!=0)
Print(GetErrorDescription(result,InpLanguage));
}
}
//+------------------------------------------------------------------+
int PositionCount(const string _symbol)
{
int count=0;
int orders_total=OrdersTotal();
for(int i=0; i<orders_total; i++)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
PrintError(ERR_ORDER_SELECT);
return(-1);
}
//---
if(_symbol==NULL || OrderSymbol()==_symbol)
count++;
}
//---
return(count);
}
//+------------------------------------------------------------------+
int SendScreenShot(const long _chat_id,
const string _symbol,
const ENUM_TIMEFRAMES _period,
const string _template=NULL)
{
int result=0;
long chart_id=ChartOpen(_symbol,_period);
if(chart_id==0)
return(ERR_CHART_NOT_FOUND);
ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);
//--- actualizar gráfico
int wait=60;
while(--wait>0)
{
if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))
break;
Sleep(500);
}
if(_template!=NULL)
if(!ChartApplyTemplate(chart_id,_template))
PrintError(_LastError,InpLanguage);
ChartRedraw(chart_id);
Sleep(500);
ChartSetInteger(chart_id,CHART_SHOW_GRID,false);
ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);
string filename=StringFormat("%s%d.gif",_symbol,_period);
if(FileIsExist(filename))
FileDelete(filename);
ChartRedraw(chart_id);
Sleep(100);
// if(ChartScreenShot(chart_id,filename,800,600,ALIGN_RIGHT))
if(ChartScreenShot(chart_id,filename,1024,768,ALIGN_RIGHT))
{
Sleep(100);
bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);
//--- espera 30 segundos para guardar la captura de pantalla
wait=60;
while(!FileIsExist(filename) && --wait>0)
Sleep(500);
//---
string screen_id;
result=bot.SendPhoto(_chat_id,filename,screen_id,_symbol+"_"+StringSubstr(EnumToString(_period),7));
}
ChartClose(chart_id);
return(result);
}
//+------------------------------------------------------------------+
Hola a todos,
Estoy intentando enviar un mensaje desde MT5 a Telegram utilizando un bot. Sin embargo, no he podido enviar el mensaje desde MT5 a Telegram debido al error: Código de error 400 Descripción "Bad request: chat not found"
¿Alguien se ha encontrado con el mismo problema? ¿Puede dar algunas razones por las que este error puede haber ocurrido?
Hice un montón de investigación en línea, pero no pude obtener las respuestas correctas.
Foro sobre trading, sistemas automatizados de trading y prueba de estrategias de trading
Añadir emoji en los mensajes de telegram.
Frédéric LEBRE, 2023.12.04 13:56
Hola,
Por favor, ¿podría ayudarme.
Intento enviar un mensaje a telegram utilizando emoji.
cuando el unicode del emoji es por ejemplo : U+2702 uso como valor de cadena " \x2702 " y si funciona.
SendTelegramMessage(TelegramApiUrl, TelegramBotToken, ChatId, "\x2702");
Pero cuando unicode es así : U+1F648 nada funciona.
Incluí <Telegram.mqh> como leí en los temas, pero no sé cómo hacer más.
Gracias por sus respuestas.
He encontrado cómo hacerlo, si alguien está interesado, por favor pregúnteme).
Encontrado cómo hacerlo, cualquier persona interesada preguntar )
Podrías escribirlo. Para que otros no tengan que buscarte y preguntar.