FastNLExamples/Src/Scripts/EventCodeToId.mq5
50 lines
2 KiB
MQL5
Nique_372
2026-11-04 12:54:16 -05:00
//+------------------------------------------------------------------+
//| EventCodeToId.mq5 |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
Nique_372
2026-11-05 12:09:22 -05:00
#property script_show_inputs
Nique_372
2026-11-04 12:54:16 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include <TSN\\FastNL\\Main.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
input string InpStr = "producer-price-index-mm";
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
Nique_372
2026-11-05 12:09:22 -05:00
//---
if(InpStr[0] == '#')
{
MqlCalendarEvent event[1];
const ulong id = ulong(InpStr.Substr(1, StringLen(InpStr)));
CalendarEventById(id, event[0]);
ArrayPrint(event);
MqlCalendarValue values[];
Print(CalendarValueHistoryByEvent(id, values, 0));
return;
}
Nique_372
2026-11-04 12:54:16 -05:00
//---
ulong events_id[];
const int t = TSN::CalendarByLeo_ParseStrEvents(CALENDAR_COUNTRY_CODE_HASH_US, InpStr, ',', events_id);
for(int i = 0; i < t; i++)
{
MqlCalendarEvent event;
CalendarEventById(events_id[i], event);
Nique_372
2026-11-05 12:09:22 -05:00
Print("code: ", event.event_code, " id: ", events_id[i]);
Nique_372
2026-11-04 12:54:16 -05:00
}
}
//+------------------------------------------------------------------+
Nique_372
2026-11-05 12:09:22 -05:00
//+------------------------------------------------------------------+