//+------------------------------------------------------------------+ //| TelegramNews.mq5 | //| Copyright 2025, Leo. | //| https://www.mql5.com/es/users/nique_372/news | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, Leo." #property link "https://www.mql5.com/es/users/nique_372/news" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "Main.mqh" #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ sinput group "-------| Configuration |-------" sinput group "--| News TBP License " input string InpTbpLicense = THE_BOT_PLACE_USER_ID; // Put here your user-id TBP sinput group "--| Telegram " input string InpBotToken = ""; // Telegram bot token input long InpChatId = 0; // Telegram chat id sinput group "--| News " input datetime fecha_desde_incio_noticias = D'2005.01.01'; //Start date for calendar data collection (equal to generated csv files) input uint8_t seg_antes_despues = 15; //Segundos antes para la alerta input string importancia_eventos_a_filtrar = "High|Medium|Low"; // Importancia a filtra separadas por | //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ TSN::CBarControlerFastMinors controler_d1(PERIOD_D1); CTelegramsNews telegram; TSN::ICalendarByLeo* calendar = NULL; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Caledario datetime desde = fecha_desde_incio_noticias; datetime hasta = iTime(_Symbol, PERIOD_D1, 0); //--- #ifdef TSN_FASTNL_FUNC_CTS TSN_FASTNL_FUNC_CTS(InpTbpLicense); #else CiNewsLeo_CalendarInit(InpTbpLicense); #endif // Calendario calendar = CiNewsLeo_CreateEconomicCalendar(); if(calendar == NULL) { FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, "Error in create economic calendar (check your license)"); return INIT_PARAMETERS_INCORRECT; } // añadimos a USA con los codigos de evenytos calendar.AddAllCountries(importancia_eventos_a_filtrar); //luego de añadir los eventos tenemos que configurar el calendario calendar.SetNoticiasChecker(seg_antes_despues, 10); calendar.SetObtenerValoresActuales(false); calendar.SetCalendar(desde, hasta); // tambien añadimos el hook calendar.AddHook(&telegram); //--- // news if(!telegram.Init(_Symbol)) { FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("error in get data for symbol = %s", _Symbol)); return INIT_PARAMETERS_INCORRECT; } // tlg TSN::CTelegramAPI* tlg_api = telegram.GetBotPtr(); tlg_api.ChatId(InpChatId); //Pon el chat id donde se enviaran los mensajes tlg_api.Token(InpBotToken); // Pon el token de tu bot de telegram //--- calendar.First(TimeCurrent()); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(calendar != NULL) delete calendar; } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- const datetime time_curr = TimeCurrent(); //--- if(controler_d1.IsNewBar(time_curr)) { calendar.OnNewDay(time_curr); } //--- calendar.OnTickEvent(time_curr); //--- Buscamos si hay noticias ya establecidas para loguear o continuar con las siguientes if(calendar.NewsIsComming()) //Verificar si una funcion se acerca.. { calendar.GetEvents(time_curr); calendar.OnEndNews(time_curr); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+