Librerías: Calendario - página 11

 
amrali #:

restar directamente de 12:30 (en lugar de -3 + 31*/2):

No lo he hecho a propósito, porque supongo que en el futuro será posible cambiar los parámetros de entrada de CalendarValueHistoryByEvent.

 
fxsaber #:

No lo he hecho a propósito, porque supongo que en el futuro será posible cambiar los parámetros de entrada de CalendarValueHistoryByEvent.

puede utilizar:

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

Tras actualizar la biblioteca, el Calendario debe sincronizarse con el historial de cotizaciones de cualquier corredor.

...

¿Han eliminado la ordenación por tiempo en la última versión?


 
Anatoli Kazharski #:

¿Han eliminado la clasificación por tiempo en la última versión?

Sí. Estaba seguro de que las MQ estaban ordenadas. Me equivoqué.


ZY Añadido.

 

Desgraciadamente, no se puede confiar en el Calendario actual.


He aquí la omisión de una importante noticia sobre el CHF en la lista de acontecimientos y la correspondiente reacción del mercado a la misma.


Y este es otro calendario, donde la noticia está presente.


 

En el Tutorial encontré un tesoro de información sobre cómo trabajar con el Calendario. En particular, en el Probador.

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

Indicador de noticias con caché de calendario en el Probador

La presencia de la caché de calendario permite probar estrategias de trading sobre noticias. Lo mostraremos en la siguiente sección.

Utiliza la misma API que el calendario nativo MQL5.
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
Учебник по MQL5: Расширенные средства языка / Экономический календарь / Перенос базы календаря в тестер
  • www.mql5.com
Календарь доступен для MQL-программ только в режиме онлайн, в связи с чем тестирование новостных торговых стратегий представляет некоторую...
 

Mismo código, resultados diferentes según el símbolo del gráfico. He probado 2 brokers.

calendario_prueba.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)

He rastreado la raíz del error: DST::IsEurope() devuelve erróneamente true para estos brokers DST_US porque el algo implementado en DST::RolloverTime() no es fiable (es decir, escanea 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);  // Extraer eventos.

      for(int i = ArraySize(eEvents) - 1; i >= 0; i--)
        {
         if(eEvents[i].TimeMode == CALENDAR_TIMEMODE_DATETIME ||
            eEvents[i].TimeMode == CALENDAR_TIMEMODE_TENTATIVE)
           {
            //--- Convertir la hora del servidor -> GMT
            eEvents[i].time += DST::TimeServerGMTOffset();

            //--- Convertir GMT -> de nuevo a la hora del servidor (usando los desfases correctos)
            eEvents[i].time = CTimeZoneInfo::ConvertTimeForPlace(eEvents[i].time, ZONE_ID_UTC, ZONE_ID_BROKER);
           }
        }

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

      Print(Calendar.ToString());
     }
  }

Ahora los resultados son correctos:

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 esto te ayude a arreglar la lib.

 
amrali #:

Mismo código, resultados diferentes según el símbolo del gráfico. He probado 2 corredores.

He rastreado la raíz del error: DST::IsEurope() devuelve erróneamente true para estos brokers DST_US porque el algo implementado en DST::RolloverTime() no es fiable (es decir, escanea spreads).


test_calendar_fixed.mq5

Ahora los resultados son correctos:

Espero que esto te ayude a arreglar la lib.

Muchas gracias por encontrar el error, un ejemplo de cómo reproducirlo y la solución propuesta.


He hecho cambios en el archivo DST.mqh.

 

No está totalmente fijado en los corredores 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, también hay otro problema con los brokers 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 los servidores de exness nunca cambian a DST. Nueva York es GMT-5 en los meses de invierno, por lo que NFP a las 08:30 am hora de Nueva York debe coincidir con (08:30 + 5:00 offset) = 13:30 hora del servidor Exness.
 
fxsaber #:

Por desgracia, no puedes fiarte del Calendario actual.

Lamentablemente, el MQ-Calendar contiene errores en la hora de los acontecimientos, incluso del día actual.

La noticia era a las 07:30 (en el calendario alternativo de arriba y en el gráfico de símbolos), y el MQ-Calendar dice (incluida la versión Web) que la noticia será una hora más tarde.