mqlCalender Actual Value Event

 

today is saw a great tutorial about a newsfilter.

The filter calls the events and check if there important for the pair im trading to.

nice way to escape voilent moments... but i really like to try to work with the calender.

i want to call the actual value of the last event. So i can check if the value i bettter then expect ( or worser ofcoure).

its part of the mqlCalendervalue structure and i try to figur out hoe to call the actual value.


i will show you the code of the tutorial .


//+------------------------------------------------------------------+
//|                                                       NewsEA.mq5 |
//|                                  Copyright 2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+-----------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"



//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
    NewsFilter();
   
   
   
  }
//+------------------------------------------------------------------+

bool NewsFilter () {


MqlCalendarValue CalenderValue[] ;
   
   datetime StartTime = iTime(_Symbol,PERIOD_H4,0);
   datetime EndTime = StartTime+PeriodSeconds(PERIOD_D1);
   
   CalendarValueHistory(CalenderValue,StartTime,EndTime,NULL,NULL);
   
   
   for(int i = 0; i < ArraySize(CalenderValue); i++ ){
   
   MqlCalendarEvent CalenderEvent;
   CalendarEventById(CalenderValue[i].event_id,CalenderEvent);
   
   MqlCalendarCountry country;
   CalendarCountryById(CalenderEvent.country_id,country);
   
   if(StringFind(_Symbol,country.currency)< 0) continue; // show event for this pair
   
   if (CalenderEvent.importance == CALENDAR_IMPORTANCE_LOW) continue;
      if (TimeCurrent()<= CalenderValue[i].time+5*PeriodSeconds(PERIOD_M1) ){
   Print("Event",CalenderEvent.name,"is started");
   
     if(CalenderValue[i].HasActualValue()== true){
      Print ("actual value is ",CalenderValue[i].actual_value);
     
     }
   

   
   }
   }
  
   
   

   
   
   return false;   
   
   
   }
   
   
   

 


 i try to call the actual value "

 if(CalenderValue[i].HasActualValue()== true){
      Print ("actual value is ",CalenderValue[i].actual_value);
     

"but you see i did not work.

anyone know how to call the actual value? the mql5v reference has also a bool if there is a new actual valuw (false/true).

someone can tell me how to use this bool or know how to call the the actual value , let me know.

 
muntje:
CalenderValue[i].actual_value

Both CalenderValue[i].actual_value and CalenderValue[i].GetActualValue() should provide you valid values, but in different representation - as long and as double respectively (see details in the book). Your problem is not clear.

MQL5 Book: Advanced language tools / Economic calendar / Basic concepts of the calendar
MQL5 Book: Advanced language tools / Economic calendar / Basic concepts of the calendar
  • www.mql5.com
When working with the calendar, we will operate with several concepts, for the formal description of which MQL5 defines special types of structures...
 
Stanislav Korotky #:

Both CalenderValue[i].actual_value and CalenderValue[i].GetActualValue() should provide you valid values, but in different representation - as long and as double respectively (see details in the book). Your problem is not clear.

Thanks for answer!

The documentation tells me there is a bool (hasactualvalue) and i would like to use it. It return true or false. Thats what i try to do. But i stil didnt figur out how.. i hope maybe you can tell me or give me an example? 
 
muntje #:
Thanks for answer!

The documentation tells me there is a bool (hasactualvalue) and i would like to use it. It return true or false. Thats what i try to do. But i stil didnt figur out how.. i hope maybe you can tell me or give me an example? 

HasActualValue is a bool flag of existence of the actual value, GetActualValue provides the value itself (if exists). What's the problem?