Bibliothèque: Calendrier - page 11

 
amrali #:

soustraire directement de 12:30 (au lieu de -3 + 31*/2) :

Je ne l'ai pas fait exprès, car je suppose qu'à l'avenir, il sera possible de modifier les paramètres d'entrée de CalendarValueHistoryByEvent.

 
fxsaber #:

Je ne l'ai pas fait exprès, car je suppose qu'à l'avenir, il sera possible de modifier les paramètres d'entrée de CalendarValueHistoryByEvent.

vous pouvez utiliser :

   return((int)(45000 - Value[0].time % 86400));
 
fxsaber #:

Après la mise à jour de la bibliothèque, le calendrier doit être synchronisé avec l'historique des cotations de n'importe quel courtier.

...

Ont-ils supprimé le tri par heure dans la dernière version ?


 
Anatoli Kazharski #:

Le tri temporel a-t-il été supprimé dans la dernière version ?

Oui. J'étais sûr que les MQ étaient triés. Je me suis trompé.


ZY Ajouté.

 

Malheureusement, on ne peut pas se fier au calendrier actuel.


Voici l'omission d'une nouvelle importante concernant le franc suisse dans la liste des événements et la réaction correspondante du marché.


Et voici un autre calendrier, où la nouvelle est présente.


 

Dans le didacticiel, j'ai trouvé un trésor d'informations sur la façon de travailler avec le calendrier. En particulier, dans la section Tester.

Теперь мы можем выбрать индикатор CalendarMonitorCached.mq5  в тестере и увидеть в динамике, на истории, как меняется таблица новостей.

Indicateur de nouvelles avec cache de calendrier dans le Testeur

La présence du cache du calendrier vous permet de tester des stratégies de trading sur les actualités. Nous le montrerons dans la section suivante.

Il utilise la même API que le calendrier natif de MQL5.
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
  • www.mql5.com
Календарь доступен для MQL-программ только в режиме онлайн, в связи с чем тестирование новостных торговых стратегий представляет некоторую...
 

Même code, résultats différents selon le symbole du graphique. J'ai testé 2 courtiers.

test_calendar.mq5

#include "Calendar.mqh"

void OnStart()
  {
   CALENDAR Calendar;

   if(Calendar.Set(NULL, CALENDAR_IMPORTANCE_NONE, D'2023.10.1', TimeCurrent()))
     {
      Calendar.FilterByEventID(840030016); // PFN

      Calendar.AutoDST();

      Print(Calendar.ToString());
     }
  }

FXOpen :

test_calendar (EURUSD,M1)       2023.10.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (EURUSD,M1)       2023.11.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (EURUSD,M1)       2023.12.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (EURUSD,M1)       2024.01.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (EURUSD,M1)       2024.02.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (EURUSD,M1)       2024.03.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (EURUSD,M1)       2024.04.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (EURUSD,M1)       
test_calendar (XAUUSD,M1)       2023.10.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (XAUUSD,M1)       2023.11.03 14:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (XAUUSD,M1)       2023.12.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (XAUUSD,M1)       2024.01.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (XAUUSD,M1)       2024.02.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (XAUUSD,M1)       2024.03.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (XAUUSD,M1)       2024.04.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (XAUUSD,M1)       
BrokerDaylightSchedule (XAUUSD,M1)      Server : FXOpen-MT5
BrokerDaylightSchedule (XAUUSD,M1)      Time   : 2024.04.13 03:05:59
BrokerDaylightSchedule (XAUUSD,M1)      Offset : GMT+3
BrokerDaylightSchedule (XAUUSD,M1)      DST_US : server dst begins on the second Sunday of March (+1) and ends on the first Sunday of November (-1)

Trading.com

test_calendar (EURUSD,H4)       2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (EURUSD,H4)       2023.11.03 07:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (EURUSD,H4)       2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (EURUSD,H4)       2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (EURUSD,H4)       2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (EURUSD,H4)       2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (EURUSD,H4)       2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (EURUSD,H4)       
test_calendar (USDJPY,H1)       2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (USDJPY,H1)       2023.11.03 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (USDJPY,H1)       2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (USDJPY,H1)       2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (USDJPY,H1)       2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (USDJPY,H1)       2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (USDJPY,H1)       2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (USDJPY,H1)       
BrokerDaylightSchedule (USDJPY,H1)      Server : Trading.comMarkets-MT5
BrokerDaylightSchedule (USDJPY,H1)      Time   : 2024.04.12 20:06:30
BrokerDaylightSchedule (USDJPY,H1)      Offset : GMT-4
BrokerDaylightSchedule (USDJPY,H1)      DST_US : server dst begins on the second Sunday of March (+1) and ends on the first Sunday of November (-1)

J'ai trouvé l'origine de l'erreur : DST::IsEurope() renvoie à tort true pour ces courtiers DST_US parce que l'algo implémenté dans DST::RolloverTime() n'est pas fiable (c'est-à-dire qu'il scrute les spreads).

test_calendar_fixed.mq5

#include "Calendar.mqh"
#include "TimeZoneInfo.mqh"  // https://www.mql5.com/en/code/48419

void OnStart()
  {
   CALENDAR Calendar;

   if(Calendar.Set(NULL, CALENDAR_IMPORTANCE_NONE, D'2023.10.1', TimeCurrent()))
     {
      Calendar.FilterByEventID(840030016); // PFN

      //Calendar.AutoDST() ;

      //-----------------------------------------------------------------------
      EVENT eEvents[];
      Calendar.GetEvents(eEvents);  // Extraire des événements.

      for(int i = ArraySize(eEvents) - 1; i >= 0; i--)
        {
         if(eEvents[i].TimeMode == CALENDAR_TIMEMODE_DATETIME ||
            eEvents[i].TimeMode == CALENDAR_TIMEMODE_TENTATIVE)
           {
            //--- Convertir les heures du serveur -> GMT
            eEvents[i].time += DST::TimeServerGMTOffset();

            //--- Convertir les heures GMT -> en heures serveur (en utilisant les décalages corrects)
            eEvents[i].time = CTimeZoneInfo::ConvertTimeForPlace(eEvents[i].time, ZONE_ID_UTC, ZONE_ID_BROKER);
           }
        }

      Calendar = eEvents;  // Restaurer les événements
      //-----------------------------------------------------------------------

      Print(Calendar.ToString());
     }
  }

Les résultats sont maintenant corrects :

test_calendar_fixed (EURUSD,H4) 2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar_fixed (EURUSD,H4) 2023.11.03 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar_fixed (EURUSD,H4) 2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar_fixed (EURUSD,H4) 2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar_fixed (EURUSD,H4) 2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar_fixed (EURUSD,H4) 2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar_fixed (EURUSD,H4) 2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar_fixed (EURUSD,H4) 
test_calendar_fixed (USDJPY,H1) 2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar_fixed (USDJPY,H1) 2023.11.03 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar_fixed (USDJPY,H1) 2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar_fixed (USDJPY,H1) 2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar_fixed (USDJPY,H1) 2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar_fixed (USDJPY,H1) 2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar_fixed (USDJPY,H1) 2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar_fixed (USDJPY,H1) 
BrokerDaylightSchedule (USDJPY,H1)      Server : Trading.comMarkets-MT5
BrokerDaylightSchedule (USDJPY,H1)      Time   : 2024.04.12 20:11:17
BrokerDaylightSchedule (USDJPY,H1)      Offset : GMT-4
BrokerDaylightSchedule (USDJPY,H1)      DST_US : server dst begins on the second Sunday of March (+1) and ends on the first Sunday of November (-1)

J'espère que cela vous aidera à corriger la librairie.

 
amrali #:

Même code, résultats différents selon le symbole du graphique. J'ai testé 2 courtiers.

J'ai trouvé l'origine de l'erreur : DST::IsEurope() renvoie à tort true pour ces courtiers DST_US parce que l'algo implémenté dans DST::RolloverTime() n'est pas fiable (c'est-à-dire qu'il scanne les spreads).


test_calendar_fixed.mq5

Les résultats sont maintenant corrects :

J'espère que cela vous aidera à corriger la librairie.

Merci beaucoup d'avoir trouvé le bogue, un exemple de la façon de le reproduire et la solution proposée !


J'ai apporté des modifications au fichier DST.mqh.

 

Pas totalement fixé sur les courtiers DST_US.

test_calendar (USDJPY,H1)       2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (USDJPY,H1)       2023.11.03 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (USDJPY,H1)       2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (USDJPY,H1)       2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (USDJPY,H1)       2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (USDJPY,H1)       2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (USDJPY,H1)       2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (USDJPY,H1)       
test_calendar (EURUSD,H4)       2023.10.06 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (EURUSD,H4)       2023.11.03 07:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (EURUSD,H4)       2023.12.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (EURUSD,H4)       2024.01.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (EURUSD,H4)       2024.02.02 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (EURUSD,H4)       2024.03.08 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (EURUSD,H4)       2024.04.05 08:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (EURUSD,H4)       
BrokerDaylightSchedule (EURUSD,H4)      Server : Trading.comMarkets-MT5
BrokerDaylightSchedule (EURUSD,H4)      Time   : 2024.04.13 17:40:05
BrokerDaylightSchedule (EURUSD,H4)      Offset : GMT-4
BrokerDaylightSchedule (EURUSD,H4)      DST_US : server dst begins on the second Sunday of March (+1) and ends on the first Sunday of November (-1)

Attention, il existe également un autre problème avec les courtiers DST_NONE :

test_calendar (EURUSDm,M5)      2023.10.06 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar (EURUSDm,M5)      2023.11.03 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar (EURUSDm,M5)      2023.12.08 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar (EURUSDm,M5)      2024.01.05 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar (EURUSDm,M5)      2024.02.02 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar (EURUSDm,M5)      2024.03.08 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar (EURUSDm,M5)      2024.04.05 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar (EURUSDm,M5)      
test_calendar_fixed (EURUSDm,M5)        2023.10.06 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
test_calendar_fixed (EURUSDm,M5)        2023.11.03 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
test_calendar_fixed (EURUSDm,M5)        2023.12.08 13:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
test_calendar_fixed (EURUSDm,M5)        2024.01.05 13:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
test_calendar_fixed (EURUSDm,M5)        2024.02.02 13:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
test_calendar_fixed (EURUSDm,M5)        2024.03.08 13:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
test_calendar_fixed (EURUSDm,M5)        2024.04.05 12:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 303 K | 176 K | 275 K | 270 K
test_calendar_fixed (EURUSDm,M5)        
BrokerDaylightSchedule (EURUSDm,M5)     Server : Exness-MT5Trial
BrokerDaylightSchedule (EURUSDm,M5)     Time   : 2024.04.13 21:46:15
BrokerDaylightSchedule (EURUSDm,M5)     Offset : GMT+0
BrokerDaylightSchedule (EURUSDm,M5)     DST_NONE
Les serveurs exness ne passent jamais à l'heure d'été. New York est GMT-5 pendant les mois d'hiver, de sorte que le PFN à 08h30 heure de New York devrait correspondre à (08h30 + 5h00 de décalage) = 13h30 heure du serveur Exness.
 
fxsaber #:

Malheureusement, on ne peut pas faire confiance au calendrier actuel.

Très malheureusement, le calendrier MQ contient des erreurs dans la chronologie des événements, même pour la journée en cours.

Les nouvelles étaient à 07:30 (sur le calendrier alternatif ci-dessus et sur le graphique des symboles), et le calendrier MQ indique (y compris la version Web) que les nouvelles seront diffusées une heure plus tard.