La biblioteca se ha actualizado para permitir la modificación de eventos.
#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/es/code/32430voidOnStart()
{
CALENDAR Calendar;
conststring Currencies[] = {SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE),
SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT)};
// Tomó los próximos eventos importantes por símbolo monedas.
Calendar.Set(Currencies);
Print(Calendar.ToString()); // Los imprimí.
EVENT Events[];
if (Calendar.GetEvents(Events) > 0) // Obtiene todos los eventos en formato interno.
{
Events[0].Importance = (ENUM_CALENDAR_EVENT_IMPORTANCE)27; // Cambia la importancia del evento.
Calendar = Events; // Poner eventos en el Calendario.Print(Calendar.ToString()); // Los imprimí.
}
}
Parece que tengo un corrector de Calendario que coincide con el servidor de trading.
#property script_show_inputsinputulong inEventID = 840030006; // EventIDinputstring inName = ""; // Name -> EventID (Nonfarm Payrolls -> 840030016)inputdatetime inFrom = D'2020.01.01';
inputbool inDST = true;
voidOnStart()
{
CALENDAR Calendar;
if (inName == "")
{
Calendar.Set(inEventID);
Calendar.FilterByTime(inFrom, TimeCurrent());
Calendar.CorrectTime(); // Bypass MQL-calendar peculiaridades: https://www.mql5.com/ru/forum/444094/page14#comment_46213385if (inDST)
Calendar.DST(); // Llamar si el servidor de comercio está sincronizado con la hora europea.for (int i = Calendar.GetAmount() - 1; i >= 0; i--)
{
const EVENT Event = Calendar[i];
constdatetime ChartNews = ChartNewsTime(Event.time); // https://www.mql5.com/ru/forum/357793/page5#comment_44225999if (Event.time != ChartNews)
Print("-" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " != " + Event.ToString());
elsePrint("+" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " == " + Event.ToString());
}
}
else// Obtener EventID por nombre.
{
string Currencies[2];
// Obtener las monedas del carácter actual.
Currencies[0] = ::SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE);
Currencies[1] = ::SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT);
if (Calendar.Set(Currencies, CALENDAR_IMPORTANCE_MODERATE, inFrom) && Calendar.FilterByName(inName))
for (int i = Calendar.GetAmount() - 1; i >= 0; i--)
Print((string)Calendar[i].EventID + ": " + Calendar[i].ToString());
}
}
Resultado.
+840030016: 2023.04.0715:30 == 2023.04.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 236 K | -8 K | 311 K | 326 K
+840030016: 2023.03.1015:30 == 2023.03.1015:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 311 K | -35 K | 517 K | 504 K
+840030016: 2023.02.0315:30 == 2023.02.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 517 K | 16 K | 223 K | 260 K
+840030016: 2023.01.0615:30 == 2023.01.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 223 K | 57 K | 263 K | 256 K
+840030016: 2022.12.0215:30 == 2022.12.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | -30 K | 261 K | 284 K
+840030016: 2022.11.0414:30 == 2022.11.0414:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 261 K | -97 K | 263 K | 315 K
+840030016: 2022.10.0715:30 == 2022.10.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | 33 K | 315 K |
+840030016: 2022.09.0215:30 == 2022.09.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 315 K | 156 K | 528 K | 526 K
Coincide con el Web-calendario. Si alguien ve alguna incoherencia evidente, que me avise.
Ahora parece que es correcto usar el calendario para backtests.
No se puede comparar por 840200001-event, ya que influye poco en las cotizaciones - el tiempo de la columna izquierda puede estar calculado incorrectamente.
fxsaber #: No se puede comparar por 840200001-evento, porque tiene una influencia débil en las cotizaciones - el tiempo de la columna de la izquierda puede ser calculado incorrectamente.
Gracias, he mirado más detenidamente y entiendo el método propuesto.
Creo que para algunos casos sería más interesante mirar un cierto rango de tiempo (antes y después del evento) para ver cuánto ha cambiado el precio.
Después de actualizar la biblioteca Calendario debe sincronizarse con el historial de cotizaciones en cualquier broker.
Comprobación (ejecutada en EURUSD).
#property script_show_inputsinputulong inEventID = 840030016; // EventID (840030016 - Nonfarm Payrolls)inputdatetime inFrom = D'2020.01.01';
// Tamaño de la barra de tiempo.double GetBarSize( constdatetime Time )
{
MqlRates Rates[];
return(CopyRates(_Symbol, PERIOD_M1, iBarShift(_Symbol, PERIOD_M1, Time), 1, Rates) != 1 ? 0 : Rates[0].high - Rates[0].low);
}
// Tiempo de la barra más grande por tamaño (por tiempo del array).datetime GetMaxBarSizeTime( constdatetime &Times[] )
{
double Values[];
for (int i = ArrayResize(Values, ArraySize(Times)) - 1; i >= 0; i--)
Values[i] = GetBarSize(Times[i]);
return(Times[ArrayMaximum(Values)]);
}
// Momento más probable de noticias sobre datos de precios (reacción fuerte).datetime ChartNewsTime( constdatetime &Time )
{
datetime Times[3];
Times[0] = Time;
Times[1] = Times[0] - 3600;
Times[2] = Times[0] + 3600;
return(GetMaxBarSizeTime(Times));
}
#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/es/code/32430#define PRINT(A) Print(#A + " = " + (string)(A))
voidOnStart()
{
PRINT(AccountInfoString(ACCOUNT_SERVER));
PRINT(TimeTradeServer());
PRINT(DST::IsEurope()); // Reglamento europeo DST.
PRINT(DST::GetRollover()); // Tiempo de vuelco.
PRINT(DST::TimeServerGMTOffset()); // GMT desplazamiento del servidor.
CALENDAR Calendar;
Calendar.Set(inEventID);
Calendar.FilterByTime(inFrom, TimeCurrent());
Calendar.AutoDST();for (int i = Calendar.GetAmount() - 1; i >= 0; i--)
{
const EVENT Event = Calendar[i];
constdatetime ChartNews = ChartNewsTime(Event.time);
if (Event.time != ChartNews)
Print("-" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " != " + Event.ToString());
elsePrint("+" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " == " + Event.ToString());
}
}
Resultado.
AccountInfoString(ACCOUNT_SERVER) = RannForex-Server
TimeTradeServer() = 2024.03.1409:26:54
DST::IsEurope() = 1
DST::GetRollover() = 2024.03.1323:00:00
DST::TimeServerGMTOffset() = -7200
+840030016: 2024.03.0815:30 == 2024.03.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
+840030016: 2024.02.0215:30 == 2024.02.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
+840030016: 2024.01.0515:30 == 2024.01.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
+840030016: 2023.12.0815:30 == 2023.12.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K |
+840030016: 2023.11.0314:30 == 2023.11.0314:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
+840030016: 2023.10.0615:30 == 2023.10.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
+840030016: 2023.09.0115:30 == 2023.09.0115:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 187 K | 12 K | 187 K | 157 K
+840030016: 2023.08.0415:30 == 2023.08.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 187 K | -1 K | 209 K | 185 K
+840030016: 2023.07.0715:30 == 2023.07.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 209 K | -19 K | 339 K | 306 K
+840030016: 2023.06.0215:30 == 2023.06.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 339 K | 1 K | 253 K | 294 K
+840030016: 2023.05.0515:30 == 2023.05.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 253 K | 23 K | 236 K | 165 K
+840030016: 2023.04.0715:30 == 2023.04.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 236 K | -8 K | 311 K | 326 K
+840030016: 2023.03.1015:30 == 2023.03.1015:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 311 K | -35 K | 517 K | 504 K
+840030016: 2023.02.0315:30 == 2023.02.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 517 K | 16 K | 223 K | 260 K
+840030016: 2023.01.0615:30 == 2023.01.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 223 K | 57 K | 263 K | 256 K
+840030016: 2022.12.0215:30 == 2022.12.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | -30 K | 261 K | 284 K
+840030016: 2022.11.0414:30 == 2022.11.0414:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 261 K | -97 K | 263 K | 315 K
+840030016: 2022.10.0715:30 == 2022.10.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | 33 K | 315 K |
+840030016: 2022.09.0215:30 == 2022.09.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 315 K | 156 K | 528 K | 526 K
+840030016: 2022.08.0515:30 == 2022.08.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 528 K | -19 K | 372 K | 398 K
+840030016: 2022.07.0815:30 == 2022.07.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 372 K | -229 K | 390 K | 384 K
+840030016: 2022.06.0315:30 == 2022.06.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 390 K | -19 K | 428 K | 436 K
+840030016: 2022.05.0615:30 == 2022.05.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 428 K | 317 K | 431 K | 428 K
+840030016: 2022.04.0115:30 == 2022.04.0115:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 431 K | 80 K | 678 K | 750 K
+840030016: 2022.03.0415:30 == 2022.03.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 678 K | -413 K | 467 K | 481 K
+840030016: 2022.02.0415:30 == 2022.02.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 467 K | -192 K | 199 K | 510 K
+840030016: 2022.01.0715:30 == 2022.01.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | 379 K | 210 K | 249 K
+840030016: 2021.12.0315:30 == 2021.12.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 210 K | 330 K | 531 K | 546 K
+840030016: 2021.11.0514:30 == 2021.11.0514:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 531 K | -54 K | 194 K | 312 K
+840030016: 2021.10.0815:30 == 2021.10.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 194 K | -302 K | 235 K | 366 K
+840030016: 2021.09.0315:30 == 2021.09.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 235 K | 23 K | 943 K | 1053 K
+840030016: 2021.08.0615:30 == 2021.08.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 943 K | 381 K | 850 K | 938 K
+840030016: 2021.07.0215:30 == 2021.07.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 850 K | 3 K | 559 K | 583 K
+840030016: 2021.06.0415:30 == 2021.06.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 559 K | -396 K | 266 K | 278 K
+840030016: 2021.05.0715:30 == 2021.05.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 266 K | -1 K | 916 K | 770 K
+840030016: 2021.04.0215:30 == 2021.04.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 916 K | 409 K | 379 K | 468 K
+840030016: 2021.03.0515:30 == 2021.03.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 379 K | -137 K | 49 K | 166 K
+840030016: 2021.02.0515:30 == 2021.02.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 49 K | -497 K | -140 K | -227 K
+840030016: 2021.01.0815:30 == 2021.01.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -140 K | 207 K | 245 K | 336 K
+840030016: 2020.12.0415:30 == 2020.12.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 245 K | 528 K | 638 K | 610 K
+840030016: 2020.11.0615:30 == 2020.11.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 638 K | -76324 K | 661 K | 672 K
-840030016: 2020.10.0216:30 != 2020.10.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 661 K | 78356 K | 1371 K | 1489 K
+840030016: 2020.09.0415:30 == 2020.09.0415:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 1371 K | -74433 K | 1763 K | 1734 K
+840030016: 2020.08.0715:30 == 2020.08.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 1763 K | 4511 K | 4800 K | 4791 K
+840030016: 2020.07.0215:30 == 2020.07.0215:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 4800 K | -12034 K | 2509 K | 2699 K
+840030016: 2020.06.0515:30 == 2020.06.0515:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 2509 K | -10000 K | -20500 K | -20687 K
+840030016: 2020.05.0815:30 == 2020.05.0815:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -20500 K | 139 K | -701 K | -870 K
+840030016: 2020.04.0315:30 == 2020.04.0315:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -701 K | 163 K | 273 K | 275 K
+840030016: 2020.03.0615:30 == 2020.03.0615:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 273 K | 161 K | 225 K | 273 K
+840030016: 2020.02.0715:30 == 2020.02.0715:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 225 K | 161 K | 145 K | 147 K
+840030016: 2020.01.1015:30 == 2020.01.1015:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 145 K | 168 K | 266 K | 256 K
Será necesario comprobar la corrección durante la desincronización Europa/Estados Unidos en otoño.
Ahora puede utilizar el calendario en backtests (el EA de ejemplo en la entrega ha sido actualizado).
Tengo un mal presentimiento sobre la corrección de esta función.
Usando los límites del cálculo: el rango de salida para (x % 24) es de 0 a 23, por lo que el rango de salida de la función es de -3 a 20. por lo tanto un servidor de -5 no puede ser representado.
Tengo un mal presentimiento sobre la corrección de esta función.
Usando los límites del cálculo: el rango de salida para (x % 24) es de 0 a 23, por lo que el rango de salida de la función es de -3 a 20. por lo tanto un servidor de -5 no puede ser representado.
Sobre la relevancia de los datos del calendario.
Para comparar el trabajo de otra fuente.
Resultado.
Foro sobre trading, sistemas automatizados de trading y prueba de estrategias de trading
Bibliotecas: Calendario
fxsaber, 2023.04.13 00:07 pm.
Parece que tengo un corrector de Calendario que coincide con el servidor de trading.
Resultado.
Coincide con el Web-calendario. Si alguien ve alguna incoherencia evidente, que me avise.
Ahora parece que es correcto usar el calendario para backtests.
Obtuve este resultado:
Parece que resultó ser un corrector de Calendario que coincide con el servidor de comercio.
Resultado.
Coincide con el Calendario Web. Si alguien ve alguna discrepancia obvia, que me avise.
Ahora parece que es correcto utilizar el calendario para backtests.
Las inconsistencias se ven por todos lados:
//---
Por favor, compruébelo usted también.
Se observanincoherencias en todos los ámbitos
No se puede comparar por 840200001-evento, porque tiene una influencia débil en las cotizaciones - el tiempo de la columna de la izquierda puede ser calculado incorrectamente.
Gracias, he mirado más detenidamente y entiendo el método propuesto.
Creo que para algunos casos sería más interesante mirar un cierto rango de tiempo (antes y después del evento) para ver cuánto ha cambiado el precio.
Se observanincoherencias
Después de actualizar la biblioteca Calendario debe sincronizarse con el historial de cotizaciones en cualquier broker.
Comprobación (ejecutada en EURUSD).
Resultado.
Será necesario comprobar la corrección durante la desincronización Europa/Estados Unidos en otoño.
Ahora puede utilizar el calendario en backtests (el EA de ejemplo en la entrega ha sido actualizado).
ZY te recomiendo que mires los trabajos de este autor.
Tengo un mal presentimiento sobre la corrección de esta función.
Usando los límites del cálculo: el rango de salida para (x % 24) es de 0 a 23, por lo que el rango de salida de la función es de -3 a 20. por lo tanto un servidor de -5 no puede ser representado.
Tengo un mal presentimiento sobre la corrección de esta función.
Usando los límites del cálculo: el rango de salida para (x % 24) es de 0 a 23, por lo que el rango de salida de la función es de -3 a 20. por lo tanto un servidor de -5 no puede ser representado.
Tienes razón, gracias.
restar directamente de 12:30 (en lugar de -3 + 31*/2):