Hi everyone,
I would like to create a news filter so that my eas do not trade in the two previous hours at the exit of an important news and also in the next two hours.
My problem is that I can't distinguish the important news (which I take in consideration) from those with little importance (I don't consider them).
I have seen:
But I can't "take" the value of "ENUM_CALENDAR_EVENT_IMPORTANCE importance;" that would be perfect...
Do you have any ideas that could help me? Thanks
Not exactly sure what you mean, so I crafted this small experiment based on sample codes in the MQL5 documentation:
void OnStart() { string EU_code="EU"; MqlCalendarValue values[]; datetime date_from=D'01.01.2018'; datetime date_to=0; if(CalendarValueHistory(values,date_from,date_to,EU_code)) { int idx = ArraySize(values)-1; while (idx>=0) { MqlCalendarEvent event; ulong event_id=values[idx].event_id; if(CalendarEventById(event_id,event)) PrintFormat("%s (%i)",event.name,event.importance); else PrintFormat("Failed to get event description for event_d=%s, error %d",event_id,GetLastError()); idx--; } } else { PrintFormat("Error! Failed to receive events for country_code=%s",EU_code); PrintFormat("Error code: %d",GetLastError()); } }
And I'm able to get this as output:
Not exactly sure what you mean, so I crafted this small experiment based on sample codes in the MQL5 documentation:
And I'm able to get this as output:
Thanks, and if I would use the "importance" as a variable so I would be able to insert It for example in an "if" and verify if his value is greater or lower than for example "2"
Based on the codes above, once you filled up the event structure, it'll be:
if (event.importance>2) { : }
Based on the codes above, once you filled up the event structure, it'll be:
Not exactly sure what you mean, so I crafted this small experiment based on sample codes in the MQL5 documentation:
And I'm able to get this as output:
So grateful for this effort Seng Joo!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I would like to create a news filter so that my eas do not trade in the two previous hours at the exit of an important news and also in the next two hours.
My problem is that I can't distinguish the important news (which I take in consideration) from those with little importance (I don't consider them).
I have seen:
But I can't "take" the value of "ENUM_CALENDAR_EVENT_IMPORTANCE importance;" that would be perfect...
Do you have any ideas that could help me? Thanks