Article-22235-Multiple-Regr.../events2file.mq5

32 lines
1.6 KiB
MQL5
Raw Permalink Normal View History

2026-07-09 07:53:49 +03:00
//+------------------------------------------------------------------+
//| events2file.mq5|
//| Copyright 2000-2026, MetaQuotes Ltd. |
//| www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2000-2026, MetaQuotes Ltd."
#property link "https://www.mql5.com"
//---
#property script_show_inputs
//---
input string country = "EU"; // news source
//+------------------------------------------------------------------+
//| location of the file in a shared folder \Terminal\Common\Files |
//| WARNING! Check that there is no file with this name! |
//+------------------------------------------------------------------+
input string path2file = "calendar"; // path to result file
input string file4list = "EU_events_list.txt"; // name for result file
//---
void OnStart()
{
MqlCalendarEvent events[];
if(CalendarEventByCountry(country,events)<1)
{Print("CalendarEventByCountry() error # ",GetLastError()); return;}
PrintFormat("%d events for region %s",ArraySize(events),country);
int f=FileOpen(path2file+"\\"+file4list, FILE_WRITE | FILE_TXT | FILE_COMMON);
if(f==INVALID_HANDLE)
{Print("FileOpen() error"); return;}
for(int i=0;i<ArraySize(events);++i)
FileWriteString(f,(string)events[i].id+" "+events[i].name+"\n");
FileClose(f);
}
//+------------------------------------------------------------------+