Bibliotecas: Calendário - página 11

 
amrali #:

subtrair diretamente de 12:30 (em vez de -3 + 31*/2):

Não fiz isso de propósito, porque presumo que no futuro será possível alterar os parâmetros de entrada do CalendarValueHistoryByEvent.

 
fxsaber #:

Não fiz isso de propósito, porque presumo que no futuro será possível alterar os parâmetros de entrada do CalendarValueHistoryByEvent.

você pode usar:

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

Depois de atualizar a biblioteca, o calendário deve ser sincronizado com o histórico de cotações em qualquer corretor.

...

Eles removeram a classificação por hora na versão mais recente?


 
Anatoli Kazharski #:

Eles removeram a classificação de tempo na versão mais recente?

Sim. Eu tinha certeza de que as MQs estavam classificadas. Eu estava errado.


ZY Adicionado.

 

Infelizmente, não se pode confiar no Calendário atual.


Aqui está a omissão de uma notícia importante sobre o CHF na lista de eventos e a reação correspondente do mercado a ela.


E este é outro calendário, no qual a notícia está presente.


 

No Tutorial, encontrei um tesouro de informações sobre como trabalhar com o Calendar. Em particular, no Tester.

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

Indicador de notícias com cache de calendário no Tester

A presença do cache de calendário permite que você teste estratégias de negociação com base em notícias. Mostraremos isso na próxima seção.

Ele usa a mesma API que o calendário MQL5 nativo.
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
  • www.mql5.com
Календарь доступен для MQL-программ только в режиме онлайн, в связи с чем тестирование новостных торговых стратегий представляет некоторую...
 

Mesmo código, resultados diferentes de acordo com o símbolo do gráfico. Testei 2 corretoras.

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); // NFP

      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)

Localizei a raiz do erro: DST::IsEurope() retorna erroneamente true para essas corretoras DST_US porque o algoritmo implementado em DST::RolloverTime() não é confiável (ou seja, spreads de varredura).

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); // NFP

      //Calendar.AutoDST();

      //-----------------------------------------------------------------------
      EVENT eEvents[];
      Calendar.GetEvents(eEvents);  // Extrair eventos.

      for(int i = ArraySize(eEvents) - 1; i >= 0; i--)
        {
         if(eEvents[i].TimeMode == CALENDAR_TIMEMODE_DATETIME ||
            eEvents[i].TimeMode == CALENDAR_TIMEMODE_TENTATIVE)
           {
            //--- Converta os horários do servidor -> GMT
            eEvents[i].time += DST::TimeServerGMTOffset();

            //--- Converter GMT -> de volta para os horários do servidor (usando os deslocamentos corretos)
            eEvents[i].time = CTimeZoneInfo::ConvertTimeForPlace(eEvents[i].time, ZONE_ID_UTC, ZONE_ID_BROKER);
           }
        }

      Calendar = eEvents;  // Restaurar eventos
      //-----------------------------------------------------------------------

      Print(Calendar.ToString());
     }
  }

Agora os resultados estão corretos:

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)

Espero que isso o ajude a corrigir a biblioteca.

 
amrali #:

Mesmo código, resultados diferentes de acordo com o símbolo do gráfico. Testei duas corretoras.

Localizei a raiz do erro: DST::IsEurope() retorna erroneamente true para essas corretoras DST_US porque o algoritmo implementado em DST::RolloverTime() não é confiável (ou seja, a varredura de spreads).


test_calendar_fixed.mq5

Agora os resultados estão corretos:

Espero que isso ajude você a corrigir a biblioteca.

Muito obrigado por encontrar o bug, um exemplo de como reproduzi-lo e a solução proposta!


Fiz alterações no arquivo DST.mqh.

 

Não está totalmente fixado em corretores 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)

Cuidado, pois também há outro problema com as corretoras 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
Porque os servidores da exness nunca mudam para o horário de verão. Nova York é GMT-5 nos meses de inverno, de modo que o NFP às 08:30 da manhã, horário de Nova York, deve corresponder a (08:30 + 5:00 offset) = 13:30 horário do servidor da Exness.
 
fxsaber #:

Infelizmente, não se pode confiar no Calendário atual.

Para grande pesar, o MQ-Calendar contém erros no horário dos eventos, mesmo no dia atual.

A notícia foi às 07:30 (no calendário alternativo acima e no gráfico de símbolos), e o MQ-Calendar diz (incluindo a versão da Web) que a notícia será uma hora depois.