Библиотеки: Calendar - страница 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 #:

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) ?

#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 interpret 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.

Файлы:
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% |  
 

Потому что текущее значение новости не генерируется мгновенно? В вашем примере используется метод (Event.Actual!= LONG_MIN) && (Event.Forecast!= LONG_MIN), но значения не принимаются

Что нужно сделать, чтобы в реальном тесте он принимал именно это значение и выполнялась логика вашего примера?

Gracias

 
AdrianR007 #:

Потому что текущее значение новости не генерируется мгновенно? В вашем примере используется метод (Event.Actual!= LONG_MIN) && (Event.Forecast!= LONG_MIN), но значения не принимаются

Что нужно сделать, чтобы в реальном тесте он принимал именно это значение и выполнялась логика вашего примера?

Я не понял контекста разговора.

 
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 #:
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?

Вы слишком кратко излагаете, чтобы понять однозначно, что имеете в виду. Приведите лаконичный код, который можно запустить и увидеть проблему, о которой хотите сказать.

 
fxsaber #:

Вы слишком кратко излагаете, чтобы понять однозначно, что имеете в виду. Приведите лаконичный код, который можно запустить и увидеть проблему, о которой хотите сказать.

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
Файлы:
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.

Причина обращения: