| //+------------------------------------------------------------------+
|
| //| Test2.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 "..\\..\\Secrets.mqh"
|
| #include <TSN\\FastNL\\Main.mqh>
|
| #include <TSN\\Std\\Basics\\Try.mqh>
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| input string InpUsEventList = "ism-prices-paid,building-permits,pce-price-index-mm,markit-services-pmi"; // USA Events
|
|
|
| //+------------------------------------------------------------------+
|
| //| Script program start function |
|
| //+------------------------------------------------------------------+
|
| void OnStart()
|
| {
|
| //---
|
| const datetime d = D'2018.01.01 00:00:00';
|
| const datetime h = (iTime(_Symbol, PERIOD_D1, 0) + 86400 * 2);
|
| //---
|
| #ifdef TSN_FASTNL_FUNC_CTS
|
| TSN_FASTNL_FUNC_CTS(THE_BOT_PLACE_USER_ID);
|
| #else
|
| CiNewsLeo_CalendarInit(THE_BOT_PLACE_USER_ID);
|
| #endif // TSN_MCPSERVER_FUNC_CTS
|
|
|
| //---
|
| TSN::ICalendarByLeo* calendar = CiNewsLeo_CreateEconomicCalendar();
|
|
|
| //---
|
| string _what = NULL;
|
| TSNSTD_TRY_INI
|
| {
|
| //---
|
| ulong events[];
|
| TSN:: CalendarByLeo_ParseStrEvents(CALENDAR_COUNTRY_CODE_HASH_US, InpUsEventList, ',', events);
|
|
|
| //---
|
| TSNSTD_TRY_EF(calendar.AddCountryByEventList(COUNTRY_ID_USA, events), true, CiNewsLeo_FormatTraceFirst(_what))
|
| TSNSTD_TRY_EF(calendar.SetCalendar(d, h), true, CiNewsLeo_FormatTraceFirst(_what))
|
| TSNSTD_TRY_EF(calendar.GetDataPredifinied(true), true, CiNewsLeo_FormatTraceFirst(_what))
|
|
|
| //---
|
| TSN::CEconomicEvents container[];
|
|
|
| //--- Obtener los eventos de USA (ID = 840)
|
| const int t = ArrayResize(container, calendar.ContainerGetEventsSizeByCountryId(COUNTRY_ID_USA));
|
| calendar.ContainerGetDataByCountryId(COUNTRY_ID_USA, container);
|
|
|
| //--- Imprimimo todos los event_codes
|
| for(int i = 0; i < t; i++)
|
| {
|
| const int last = ArraySize(container[i].Porcentage_Array);
|
| EconomicEventLogFull(container[i].Porcentage_Array[last - 1], container[i]);
|
| }
|
| }
|
| TSNSTD_TRY_END
|
|
|
| //---
|
| if(_what != NULL)
|
| {
|
| FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, _what);
|
| }
|
|
|
| //---
|
| delete calendar;
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| void EconomicEventLogFull(const TSN::EconomicEventData &evento, const MqlCalendarEvent& ev)
|
| {
|
| //---
|
| string mul = ev.unit == CALENDAR_UNIT_PERCENT ? "%" : MultiplicadorCaledarioToString(ev.multiplier);
|
| string forecast = evento.forecast_value == ERROR_VARIABLE ? "no defined" : StringFormat("%.5f %s", evento.forecast_value, mul);
|
| string actual = evento.actual_value == ERROR_VARIABLE ? "no defined" : StringFormat("%.5f %s", evento.actual_value, mul);
|
| string prev = evento.prev_value == ERROR_VARIABLE ? "no defined" : StringFormat("%.5f %s", evento.prev_value, mul);
|
|
|
|
|
| //---
|
| printf("------- Event name: %s", ev.name);
|
| printf("Importance = %s\nType = %s\nActual value = %s\nPrev value = %s\nForecast value = %s\nImpact = %s\nUnit = %s\nCountry Id = %I64u\nId = %I64d\nTime = %s",
|
| ImportanciaEventToString(ev.importance),
|
| EnumToString(ev.type),
|
| actual,
|
| prev,
|
| forecast,
|
| EnumToString(evento.impact),
|
| EnumToString(ev.unit),
|
| ev.country_id,
|
| ev.id,
|
| TimeToString(evento.time));
|
| }
|
| //+------------------------------------------------------------------+
|