2026-09-27 17:34:29 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| NewsTelegram.mqh |
|
| | | //| Copyright 2026, Leo. |
|
| | | //| https://www.mql5.com/es/users/nique_372/news |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Leo."
|
| | | #property link "https://www.mql5.com/es/users/nique_372/news"
|
| | | #property strict
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | // Inlcuimos el manejo de event codes
|
| | | #include <TSN\\FastNL\\EventCodesGen.mqh>
|
| | | // tambien el predict event
|
| | | #include <TSN\\FastNL\\CentralBank.mqh>
|
| | | // bueno malo tambien
|
| | | #include <TSN\\FastNL\\BuenoMalo.mqh>
|
| | | // main api aqui
|
| | | #include "..\\..\\Src\\MainAPI.mqh"
|
| | | // emojis
|
| | | #include "..\\..\\Src\\Emojis\\Emojis.mqh"
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CTelegramsNews : public TSN::CNewsEventsHook
|
| | | {
|
| | | private:
|
| | | TSN::CTelegramAPI m_bot;
|
| | | ulong m_country_id_a_cambiar;
|
2026-09-28 09:13:57 -05:00 | | |
|
| | | //---
|
2026-09-27 17:34:29 -05:00 | | | string m_symbol;
|
| | |
|
| | | //---
|
| | | string PrediccionToStr(double pred);
|
| | |
|
| | | public:
|
| | | CTelegramsNews();
|
| | | ~CTelegramsNews();
|
| | |
|
| | | //---
|
| | | inline TSN::CTelegramAPI* GetBotPtr() { return &m_bot; }
|
| | | void OnNews(const TSN::EconomicEventData& events[], const int res, const datetime curr_time) override final;
|
2026-09-28 09:13:57 -05:00 | | | bool Init(const string& symbol);
|
2026-09-27 17:34:29 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | CTelegramsNews::CTelegramsNews(void)
|
| | | : m_country_id_a_cambiar(0)
|
| | | {
|
| | | m_news_hooks_flags = NEWSBYLEO_HOOK_ON_NEWS;
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | CTelegramsNews::~CTelegramsNews()
|
| | | {
|
| | | }
|
| | |
|
2026-09-28 09:13:57 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTelegramsNews::Init(const string& symbol)
|
| | | {
|
| | | m_symbol = symbol;
|
| | | ulong temp;
|
| | | return TSN::GetCountryIdsBySymbol(m_symbol, m_country_id_a_cambiar, temp);
|
| | | }
|
2026-09-27 17:34:29 -05:00 | | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | string CTelegramsNews::PrediccionToStr(double pred)
|
| | | {
|
| | | if(pred == 10.0)
|
| | | {
|
| | | return "subira";
|
| | | }
|
| | | else
|
| | | if(pred == -10.0)
|
| | | {
|
| | | return "bajara";
|
| | | }
|
| | | else
|
| | | {
|
| | | return "no definido";
|
| | | }
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | void CTelegramsNews::OnNews(const TSN::EconomicEventData &events[], const int res, const datetime curr_time)
|
| | | {
|
| | | //---
|
| | | static const string ImportanciaAEmoji[4] = { EMOJI_GRAY_CIRCLE, EMOJI_GRAY_CIRCLE, EMOJI_YELLOW_CIRCLE, EMOJI_RED_CIRCLE};
|
| | |
|
| | | //---
|
| | | const datetime time = events[0].time;
|
| | | string str;
|
2026-09-28 09:13:57 -05:00 | | | StringReserve(str, 1024);
|
2026-09-27 17:34:29 -05:00 | | |
|
| | | //---
|
2026-09-28 09:13:57 -05:00 | | | str += StringFormat("%s Nuevas noticias programadas para las: %s\n", EMOJI_CALENDAR, TimeToString(time));
|
| | | str += "| Event | Importance | Forecast value | Prev value | Prediction |";
|
| | | str += "|:-----:|:----------:|:--------------:|:----------:|:----------:|";
|
2026-09-27 17:34:29 -05:00 | | |
|
| | | //---
|
| | | const int t = ArraySize(events);
|
| | | for(int i = 0; i < t; i++)
|
| | | {
|
| | | TSN::EconomicEventData evento = events[i];
|
| | | static MqlCalendarEvent desc;
|
| | | const uint meta = events[i].extra_meta;
|
| | | m_calendar.GetEventDesc(NEWSBYLEO_EXTRAMETA_GET_COUNTRY_IDX(meta),
|
| | | NEWSBYLEO_EXTRAMETA_GET_EVENT_IDX(meta), desc);
|
| | |
|
| | |
|
| | | //---
|
| | | const bool es_bueno_quesuba = TSN::CEnumRegFnlids::GetVal(desc.id) != NEWSBYLEO_BUENOMALO_IDX_MALO;
|
| | | const string mul = MultiplicadorCaledarioToString(desc.multiplier);
|
| | | const int idx_imp = (int)desc.importance;
|
| | | const string for_value = evento.forecast_value == ERROR_VARIABLE ? "Not Defined" : DoubleToString(evento.forecast_value, 2);
|
| | | const string prev_value = evento.prev_value == ERROR_VARIABLE ? "Not Defined" : DoubleToString(evento.prev_value, 2);
|
| | | const string prediccion = PrediccionToStr(TSN::TeoricMovementOfEventUseForecast(evento,
|
| | | desc.country_id, m_country_id_a_cambiar, true));
|
| | |
|
| | | //---
|
2026-09-28 09:13:57 -05:00 | | | str += StringFormat("| %s | %s | %s %s | %s %s | %s |\n",
|
| | | desc.name,
|
| | | ImportanciaAEmoji[idx_imp],
|
| | | mul, for_value,
|
| | | mul, prev_value,
|
| | | m_symbol,
|
| | | prediccion
|
| | | );
|
2026-09-27 17:34:29 -05:00 | | | }
|
2026-09-28 09:13:57 -05:00 | | |
|
| | | //---
|
| | | m_bot.SendRichMessageMarkdown(str, TLGBYLEO_BOOL_FALSE, TLGBYLEO_BOOL_FALSE);
|
2026-09-27 17:34:29 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|