Libraries: Calendar - page 7

 

Thanks fxsaber,

The script is great. I am new to MT5, and using your calendar script. For the historical data, how could I add the period that where the economic data are belonging to? (e.g Jan for the release data belongs to January) ?


Thanks and best regards,

Edwin

 
eapricorn period that where the economic data are belonging to? (e.g Jan for the release data belongs to January) ?
#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430

void OnStart()
{
  CALENDAR Calendar;
  
  Calendar.Set(NULL, CALENDAR_IMPORTANCE_HIGH, D'2023.01.01', D'2023.02.01');
  
  Print(Calendar.ToString());
}
 
fxsaber # :

Hi fxsaber,


Thanks for your message. I am sorry that I might have interpreted my question in a wrong way. Actually I am referring to the 'calendar window' in MT5 which normally has the 'Jan' in the period column that indicating the economic data releasing today '2 Feb 2023' is actually referring to the January economic data (as attached picture). But from the script, I see that we only have the data releasing date, while the "Period" is not specified. (as attached picture).

I have tried to search for the MqlCalendarValue, and using the Value.period for the "Period" date, but it gives very strange value, being 1970.01.01. (as attached).

Just sincerely hope to know if the period could be available, and how to add that into your script? Thank you.

Files:
Calendar.jpg  298 kb
MT5_calendar.jpg  414 kb
MetaEditor.jpg  465 kb
 
eapricorn #:

Actually I am referring to the 'calendar window' in MT5 which normally has the 'Jan' in the period column that indicating the economic data releasing today '2 Feb 2023' is actually referring to the January economic data (as attached picture).

#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430

struct CALENDAR_EVENT : public EVENT
{
  string ToString() const
  {
    struct CALENDAR_VALUE : public MqlCalendarValue
    {
      string ToString( void ) const
      {
        static const string Month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
        static const string Quarter[] = {"Q1", "Q2", "Q3", "Q4"};
        
        MqlDateTime Time;
    
        return((this.period && ::TimeToStruct(this.period, Time) ? (this.revision ? Quarter[(Time.mon - 1) / 3]
                                                                                  : Month[Time.mon - 1] + ((Time.day != 1) ? " " + (string)Time.day : NULL))
                                                                 : NULL));
      }
    } Value;

    return(this.EVENT::ToString() + (::CalendarValueById(this.id, Value) ? Value.ToString() : NULL));
  }
};

void OnStart()
{  
  CALENDAR Calendar;
  
  Calendar.Set();
  
  const int Size = Calendar.GetAmount();
  
  for (int i = 0; i < Size; i++)
  {
    const CALENDAR_EVENT Event = Calendar[i];
    
    Print(Event.ToString());
  }
}


2023.02.02 16:15 GBP 3 BoE Governor Bailey Speech (boe-governor-bailey-speech), United Kingdom (GB) |  |  |  |  
2023.02.02 17:15 EUR 3 ECB President Lagarde Speech (ecb-president-lagarde-speech), European Union (EU) |  |  |  |  
2023.02.02 20:30 EUR 3 ECB President Lagarde Speech (ecb-president-lagarde-speech), European Union (EU) |  |  |  |  
2023.02.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) |  | 16 K | 223 K |  Jan
2023.02.03 17:00 USD 3 ISM Non-Manufacturing PMI (ism-non-manufacturing-pmi), United States (US) |  | 53 | 49.6 |  Jan
2023.02.06 12:00 EUR 3 Retail Sales m/m (retail-sales-mm), European Union (EU) |  | 0.3% | 0.8% |  Dec
2023.02.06 17:00 CAD 3 Ivey PMI (ivey-pmi), Canada (CA) |  | 55.2 | 33.4 |  Jan
2023.02.07 05:30 AUD 3 RBA Interest Rate Decision (rba-interest-rate-decision), Australia (AU) |  |  | 3.1% |  
2023.02.07 19:30 CAD 3 BoC Governor Macklem Speech (boc-governor-macklem-speech), Canada (CA) |  |  |  |  
2023.02.08 06:30 INR 3 RBI Interest Rate Decision (rbi-interest-rate-decision), India (IN) |  |  | 6.25% |  
2023.02.08 17:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) |  | -0.012 M | 4.140 M |  Feb 3
2023.02.09 AllDay EUR 3 EU Leaders Summit (eu-leaders-summit), European Union (EU) |  |  |  |  
2023.02.09 10:30 SEK 3 Riksbank Interest Rate Decision (riksbank-interest-rate-decision), Sweden (SE) |  |  | 2.5% |  
 

Because the current news value is not generated instantly? Your example uses the method (Event.Actual!= LONG_MIN) && (Event.Forecast!= LONG_MIN), but the values are not accepted

What do I need to do so that in a real test it accepts this exact value and the logic of your example is executed?

Gracias

 
AdrianR007 LONG_MIN) && (Event.Forecast!= LONG_MIN), but the values are not accepted

What should I do to make it accept this value in a real test and the logic of your example is executed?

I don't understand the context of the conversation.

 
The current value of the news is not being updated, therefore the code (Event.Actual!= LONG_MIN) && (Event.Forecast!= LONG_MIN) does not work. Is there any other way to read the event at the minute it occurs?
 
AdrianR007 LONG_MIN) && (Event.Forecast!= LONG_MIN) does not work. Is there any other way to read the event at the minute it occurs?

You are being too concise to understand clearly what you mean. Provide concise code that you can run and see the problem you want to talk about.

 
fxsaber #:

You are being too concise to understand unambiguously what you mean. Provide concise code that you can run and see the problem you want to talk about.

I am using the code from your example but the current value is not being updated when the event occurs. Any suggestion about it?
Thank you
Files:
Capture.PNG  124 kb
 
AdrianR007 #:
I am using the code from your example but the current value is not being updated when the event occurs. Any suggestion about it?
Thank you

it's not self refreshing library, use id, from calendar, for obtaining fresh data from mql5.