- Help to improve News EA
- Auto trading the news
- Stuck with an EA programming. Can anyone help this newbie?
Here: https://www.mql5.com/en/docs/calendar
you have all the function to find when what kind of events are coming up.
Some have examples to copy and paste.
- www.mql5.com
Hello sir,
I am facing difficulty in accessing date range and importance together. I can get importance of events but can't filter them for current days event only. Also, I can get current days event, but then i can't access the importance of the event. I am attaching my piece of code. Can you find errors and correct me? I would be really grateful.
Here, I was trying to set the value of global variable if_event as true if there is event with high importance in current day.
MqlDateTime time;
TimeToStruct(TimeCurrent(),time);
int currentDay= time.day;
int currentMonth= time.mon;
int currentYear= time.year;
MqlDateTime from_to;
TimeCurrent(from_to);
from_to.day = currentDay;
from_to.mon = currentMonth;
from_to.year = currentYear;
datetime from_to_date = StructToTime(from_to);
MqlCalendarEvent events[];
ulong event_imp;
ulong event_id;
int event_count = CalendarEventByCurrency("USD",events);
if (event_count > 0){
ArrayResize(events,15);
}
for(int i=0; i<=15; i++){
event_imp = events[i].importance;
event_id = events[i].id;}
MqlCalendarValue values[];
if(CalendarValueHistoryByEvent(event_id,values,from_to_date,from_to_date)){
if(event_imp = CALENDAR_IMPORTANCE_HIGH){
if_event = true;
}else {if_event = false;}
}
Here: https://www.mql5.com/en/docs/calendar
you have all the function to find when what kind of events are coming up.
Some have examples to copy and paste.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use