News filter

 

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: 

struct MqlCalendarEvent 
  { 
   ulong                               id;                    // ID evento 
   ENUM_CALENDAR_EVENT_TYPE            type;                  // tipo di evento dall'enumerazione ENUM_CALENDAR_EVENT_TYPE 
   ENUM_CALENDAR_EVENT_SECTOR          sector;                // settore a cui è collegato un evento 
   ENUM_CALENDAR_EVENT_FREQUENCY       frequency;             // frequenza degli eventi 
   ENUM_CALENDAR_EVENT_TIMEMODE        time_mode;             // modalità orario evento 
   ulong                               country_id;            // ID Paese 
   ENUM_CALENDAR_EVENT_UNIT            unit;                  // unità di misura del valore dell'indicatore economico 
   ENUM_CALENDAR_EVENT_IMPORTANCE      importance;            // importanza dell'evento 
   ENUM_CALENDAR_EVENT_MULTIPLIER      multiplier;            // moltiplicatore del valore dell'indicatore economico 
   uint                                digits;                // numero di posizioni decimali 
   string                              source_url;            // URL di una fonte in cui è pubblicato un evento 
   string                              event_code;            // codice evento 
   string                              name;                  // nome del testo dell'evento nella lingua del terminale (nella codifica del terminale corrente) 
  };

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

 
Giorgio:

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:


 
Seng Joo Thio:

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"
How can I do?
 
Giorgio:
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"
How can I do?

Based on the codes above, once you filled up the event structure, it'll be:

if (event.importance>2)
{
        :
}
 
Seng Joo Thio:

Based on the codes above, once you filled up the event structure, it'll be:

Thanks :)
 
Seng Joo Thio:

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!