Libraries: Calendar - page 10

 

On the relevance of calendar data.


For comparison the work of another source.

 
The library has been updated to allow for event modification.
#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430

void OnStart()
{
  CALENDAR Calendar;
  
  const string Currencies[] = {SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE),
                               SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT)};
  
  // Took upcoming important events by symbol currencies.
  Calendar.Set(Currencies);
  
  Print(Calendar.ToString()); // Printed them out.
  
  EVENT Events[];
  
  if (Calendar.GetEvents(Events) > 0) // Got all events in internal format.
  {    
    Events[0].Importance = (ENUM_CALENDAR_EVENT_IMPORTANCE)27; // Changed the importance of the event.

    Calendar = Events; // Put events on the Calendar.
    
    Print(Calendar.ToString()); // Printed them out.
  }
}


Result.

2024.03.06 16:45 CAD 3 BoC Interest Rate Decision (boc-interest-rate-decision), Canada (CA) |  |  | 5.0% | 
2024.03.06 17:00 CAD 3 Ivey PMI (ivey-pmi), Canada (CA) |  | 56.4 | 56.5 | 
2024.03.08 15:30 CAD 3 Employment Change (employment-change), Canada (CA) |  | 33.3 K | 37.3 K | 

2024.03.06 16:45 CAD 27 BoC Interest Rate Decision (boc-interest-rate-decision), Canada (CA) |  |  | 5.0% | 
2024.03.06 17:00 CAD 3 Ivey PMI (ivey-pmi), Canada (CA) |  | 56.4 | 56.5 | 
2024.03.08 15:30 CAD 3 Employment Change (employment-change), Canada (CA) |  | 33.3 K | 37.3 K | 
 

Forum on trading, automated trading systems and testing trading strategies

Libraries: Calendar

fxsaber, 2023.04.13 00:07 pm.

Looks like I got a Calendar corrector that matches the trading server.

#property script_show_inputs

input ulong inEventID = 840030006; // EventID
input string inName = ""; // Name -> EventID (Nonfarm Payrolls -> 840030016)
input datetime inFrom = D'2020.01.01';
input bool inDST = true;

void OnStart()
{
  CALENDAR Calendar;
    
  if (inName == "")
  {
    Calendar.Set(inEventID);
    Calendar.FilterByTime(inFrom, TimeCurrent());
    
    Calendar.CorrectTime(); // Bypass MQL-calendar peculiarities: https://www.mql5.com/ru/forum/444094/page14#comment_46213385
    
    if (inDST)
      Calendar.DST(); // Call if the trade server is synchronised with European time.
  
    for (int i = Calendar.GetAmount() - 1; i >= 0; i--)
    {
      const EVENT Event = Calendar[i];    
      const datetime ChartNews = ChartNewsTime(Event.time); // https://www.mql5.com/ru/forum/357793/page5#comment_44225999
      
      if (Event.time != ChartNews)    
        Print("-" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " != " + Event.ToString());
      else
        Print("+" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " == " + Event.ToString());
    }
  }
  else // Get EventID by name.
  {
    string Currencies[2];
    
    // Get the currencies of the current character.
    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());
  }
}


Result.

+840030016: 2023.04.07 15:30 == 2023.04.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 236 K | -8 K | 311 K | 326 K
+840030016: 2023.03.10 15:30 == 2023.03.10 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 311 K | -35 K | 517 K | 504 K
+840030016: 2023.02.03 15:30 == 2023.02.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 517 K | 16 K | 223 K | 260 K
+840030016: 2023.01.06 15:30 == 2023.01.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 223 K | 57 K | 263 K | 256 K
+840030016: 2022.12.02 15:30 == 2022.12.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | -30 K | 261 K | 284 K
+840030016: 2022.11.04 14:30 == 2022.11.04 14:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 261 K | -97 K | 263 K | 315 K
+840030016: 2022.10.07 15:30 == 2022.10.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | 33 K | 315 K | 
+840030016: 2022.09.02 15:30 == 2022.09.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 315 K | 156 K | 528 K | 526 K

Matches the Web-calendar. If anyone sees any obvious inconsistencies, let me know.

Now it seems to be correct to use the calendar for backtests.

I got this result:

OnStart > DST: false
+840030006: 2024.03.12 14:30 == 2024.03.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.3% | 0.4% | 
-840030006: 2024.02.13 15:30 != 2024.02.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.2% | 0.3% | 
-840030006: 2024.01.11 15:30 != 2024.01.11 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.3% | 0.3% | 
-840030006: 2023.12.12 15:30 != 2023.12.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.3% | 0.2% | 
-840030006: 2023.11.14 15:30 != 2023.11.14 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.3% | 0.3% | 
-840030006: 2023.10.12 15:30 != 2023.10.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.4% | 0.3% | 
-840030006: 2023.09.13 15:30 != 2023.09.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.4% | 0.2% | 
-840030006: 2023.08.10 15:30 != 2023.08.10 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.4% | 0.2% | 
-840030006: 2023.07.12 15:30 != 2023.07.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.4% | 0.4% | 
-840030006: 2023.06.13 15:30 != 2023.06.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.4% | 0.4% | 
-840030006: 2023.05.10 15:30 != 2023.05.10 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.4% | 
-840030006: 2023.04.12 15:30 != 2023.04.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.5% | 
+840030006: 2023.03.14 14:30 == 2023.03.14 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.5% | 0.5% | 0.4% | 
-840030006: 2023.02.14 15:30 != 2023.02.14 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.3% | 0.4%
-840030006: 2023.01.12 15:30 != 2023.01.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.5% | 0.2% | 

OnStart > DST: true
-840030006: 2024.03.12 14:30 != 2024.03.12 13:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.3% | 0.4% | 
-840030006: 2024.02.13 15:30 != 2024.02.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.2% | 0.3% | 
-840030006: 2024.01.11 15:30 != 2024.01.11 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.3% | 0.3% | 
-840030006: 2023.12.12 15:30 != 2023.12.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.3% | 0.2% | 
-840030006: 2023.11.14 15:30 != 2023.11.14 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.3% | 0.3% | 
-840030006: 2023.10.12 15:30 != 2023.10.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.4% | 0.3% | 
-840030006: 2023.09.13 15:30 != 2023.09.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.4% | 0.2% | 
-840030006: 2023.08.10 15:30 != 2023.08.10 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.4% | 0.2% | 
-840030006: 2023.07.12 15:30 != 2023.07.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.2% | 0.4% | 0.4% | 
-840030006: 2023.06.13 15:30 != 2023.06.13 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.4% | 0.4% | 
-840030006: 2023.05.10 15:30 != 2023.05.10 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.4% | 
-840030006: 2023.04.12 15:30 != 2023.04.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.5% | 
-840030006: 2023.03.14 14:30 != 2023.03.14 13:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.5% | 0.5% | 0.4% | 
-840030006: 2023.02.14 15:30 != 2023.02.14 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.4% | 0.5% | 0.3% | 0.4%
-840030006: 2023.01.12 15:30 != 2023.01.12 14:30 USD 2 Core CPI m/m (consumer-price-index-ex-food-energy-mm), United States (US) | 0.3% | 0.5% | 0.2% | 
 
fxsaber #:

Looks like it turned out to be a Calendar corrector that matches the trade server.

Result.

Matches the Web Calendar. If anyone sees any obvious discrepancies, let me know.

Now it seems to be correct to use the calendar for backtests.

Inconsistencies are seen all over the place:

OnStart > DST: false
-840200001: 2024.03.06 15:30 != 2024.03.06 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.367 M | 4.491 M | 4.199 M | 
-840200001: 2024.02.28 15:30 != 2024.02.28 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 4.199 M | 3.930 M | 3.514 M | 
+840200001: 2024.02.22 17:00 == 2024.02.22 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 3.514 M | 6.807 M | 12.018 M | 
+840200001: 2024.02.14 16:30 == 2024.02.14 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 12.018 M | 3.392 M | 5.520 M | 
-840200001: 2024.02.07 17:30 != 2024.02.07 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 5.520 M | -3.716 M | 1.234 M | 
-840200001: 2024.01.31 15:30 != 2024.01.31 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.234 M | -6.860 M | -9.233 M | 
+840200001: 2024.01.24 16:30 == 2024.01.24 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -9.233 M | -0.744 M | -2.492 M | 
+840200001: 2024.01.18 17:00 == 2024.01.18 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -2.492 M | 4.112 M | 1.338 M | 
-840200001: 2024.01.10 17:30 != 2024.01.10 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.338 M | -2.280 M | -5.503 M | 
+840200001: 2024.01.04 17:00 == 2024.01.04 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -5.503 M | -2.499 M | -7.114 M | 

OnStart > DST: true
-840200001: 2024.03.06 15:30 != 2024.03.06 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.367 M | 4.491 M | 4.199 M | 
-840200001: 2024.02.28 15:30 != 2024.02.28 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 4.199 M | 3.930 M | 3.514 M | 
+840200001: 2024.02.22 17:00 == 2024.02.22 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 3.514 M | 6.807 M | 12.018 M | 
+840200001: 2024.02.14 16:30 == 2024.02.14 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 12.018 M | 3.392 M | 5.520 M | 
-840200001: 2024.02.07 17:30 != 2024.02.07 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 5.520 M | -3.716 M | 1.234 M | 
-840200001: 2024.01.31 15:30 != 2024.01.31 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.234 M | -6.860 M | -9.233 M | 
+840200001: 2024.01.24 16:30 == 2024.01.24 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -9.233 M | -0.744 M | -2.492 M | 
+840200001: 2024.01.18 17:00 == 2024.01.18 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -2.492 M | 4.112 M | 1.338 M | 
-840200001: 2024.01.10 17:30 != 2024.01.10 16:30 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | 1.338 M | -2.280 M | -5.503 M | 
+840200001: 2024.01.04 17:00 == 2024.01.04 17:00 USD 3 EIA Crude Oil Stocks Change (eia-crude-oil-stocks-change), United States (US) | -5.503 M | -2.499 M | -7.114 M | 

//---

Please check this for yourself as well.

 
Anatoli Kazharski #:

Inconsistencies are observed across the board

Can't compare by 840200001-event, as it has a weak influence on quotes - left column time may be incorrectly calculated.
 
fxsaber #:
You can't compare by 840200001-event, because it has a weak influence on quotes - the time of the left column may be incorrectly calculated.

Thanks, I took a closer look and understand the proposed method.

I think for some cases it would be more interesting to look at a certain time range (before and after the event) to see how much the price has changed.

 
Anatoli Kazharski #:

Inconsistencies are observed

After updating the library Calendar should be synchronised with the quotes history on any broker.


Check (run on EURUSD).

#property script_show_inputs

input ulong inEventID = 840030016; // EventID (840030016 - Nonfarm Payrolls)
input datetime inFrom = D'2020.01.01';

// Time bar size.
double GetBarSize( const datetime Time )
{
  MqlRates Rates[];
  
  return(CopyRates(_Symbol, PERIOD_M1, iBarShift(_Symbol, PERIOD_M1, Time), 1, Rates) != 1 ? 0 : Rates[0].high - Rates[0].low);
}

// Time of the largest bar by size (by time from the array).
datetime GetMaxBarSizeTime( const datetime &Times[] )
{
  double Values[];
  
  for (int i = ArrayResize(Values, ArraySize(Times)) - 1; i >= 0; i--)
    Values[i] = GetBarSize(Times[i]);
  
  return(Times[ArrayMaximum(Values)]);
}

// Most likely time of news on price data (strong reaction).
datetime ChartNewsTime( const datetime &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/ru/code/32430
#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{ 
  PRINT(AccountInfoString(ACCOUNT_SERVER));
  PRINT(TimeTradeServer());
  PRINT(DST::IsEurope());            // European DST Regulation.
  PRINT(DST::GetRollover());         // Rollover Time.
  PRINT(DST::TimeServerGMTOffset()); // GMT server offset.
  
  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];    
    const datetime ChartNews = ChartNewsTime(Event.time);
    
    if (Event.time != ChartNews)    
      Print("-" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " != " + Event.ToString());
    else
      Print("+" + (string)Event.EventID + ": " + TimeToString(ChartNews) + " == " + Event.ToString());
  }
}


Result.

AccountInfoString(ACCOUNT_SERVER) = RannForex-Server
TimeTradeServer() = 2024.03.14 09:26:54
DST::IsEurope() = 1
DST::GetRollover() = 2024.03.13 23:00:00
DST::TimeServerGMTOffset() = -7200
+840030016: 2024.03.08 15:30 == 2024.03.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 275 K | 220 K | 353 K | 229 K
+840030016: 2024.02.02 15:30 == 2024.02.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 353 K | 186 K | 216 K | 333 K
+840030016: 2024.01.05 15:30 == 2024.01.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 216 K | 1 K | 199 K | 173 K
+840030016: 2023.12.08 15:30 == 2023.12.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | -3 K | 150 K | 
+840030016: 2023.11.03 14:30 == 2023.11.03 14:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 150 K | -8 K | 336 K | 297 K
+840030016: 2023.10.06 15:30 == 2023.10.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 336 K | 1 K | 187 K | 227 K
+840030016: 2023.09.01 15:30 == 2023.09.01 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 187 K | 12 K | 187 K | 157 K
+840030016: 2023.08.04 15:30 == 2023.08.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 187 K | -1 K | 209 K | 185 K
+840030016: 2023.07.07 15:30 == 2023.07.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 209 K | -19 K | 339 K | 306 K
+840030016: 2023.06.02 15:30 == 2023.06.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 339 K | 1 K | 253 K | 294 K
+840030016: 2023.05.05 15:30 == 2023.05.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 253 K | 23 K | 236 K | 165 K
+840030016: 2023.04.07 15:30 == 2023.04.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 236 K | -8 K | 311 K | 326 K
+840030016: 2023.03.10 15:30 == 2023.03.10 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 311 K | -35 K | 517 K | 504 K
+840030016: 2023.02.03 15:30 == 2023.02.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 517 K | 16 K | 223 K | 260 K
+840030016: 2023.01.06 15:30 == 2023.01.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 223 K | 57 K | 263 K | 256 K
+840030016: 2022.12.02 15:30 == 2022.12.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | -30 K | 261 K | 284 K
+840030016: 2022.11.04 14:30 == 2022.11.04 14:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 261 K | -97 K | 263 K | 315 K
+840030016: 2022.10.07 15:30 == 2022.10.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 263 K | 33 K | 315 K | 
+840030016: 2022.09.02 15:30 == 2022.09.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 315 K | 156 K | 528 K | 526 K
+840030016: 2022.08.05 15:30 == 2022.08.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 528 K | -19 K | 372 K | 398 K
+840030016: 2022.07.08 15:30 == 2022.07.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 372 K | -229 K | 390 K | 384 K
+840030016: 2022.06.03 15:30 == 2022.06.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 390 K | -19 K | 428 K | 436 K
+840030016: 2022.05.06 15:30 == 2022.05.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 428 K | 317 K | 431 K | 428 K
+840030016: 2022.04.01 15:30 == 2022.04.01 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 431 K | 80 K | 678 K | 750 K
+840030016: 2022.03.04 15:30 == 2022.03.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 678 K | -413 K | 467 K | 481 K
+840030016: 2022.02.04 15:30 == 2022.02.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 467 K | -192 K | 199 K | 510 K
+840030016: 2022.01.07 15:30 == 2022.01.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 199 K | 379 K | 210 K | 249 K
+840030016: 2021.12.03 15:30 == 2021.12.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 210 K | 330 K | 531 K | 546 K
+840030016: 2021.11.05 14:30 == 2021.11.05 14:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 531 K | -54 K | 194 K | 312 K
+840030016: 2021.10.08 15:30 == 2021.10.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 194 K | -302 K | 235 K | 366 K
+840030016: 2021.09.03 15:30 == 2021.09.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 235 K | 23 K | 943 K | 1053 K
+840030016: 2021.08.06 15:30 == 2021.08.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 943 K | 381 K | 850 K | 938 K
+840030016: 2021.07.02 15:30 == 2021.07.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 850 K | 3 K | 559 K | 583 K
+840030016: 2021.06.04 15:30 == 2021.06.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 559 K | -396 K | 266 K | 278 K
+840030016: 2021.05.07 15:30 == 2021.05.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 266 K | -1 K | 916 K | 770 K
+840030016: 2021.04.02 15:30 == 2021.04.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 916 K | 409 K | 379 K | 468 K
+840030016: 2021.03.05 15:30 == 2021.03.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 379 K | -137 K | 49 K | 166 K
+840030016: 2021.02.05 15:30 == 2021.02.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 49 K | -497 K | -140 K | -227 K
+840030016: 2021.01.08 15:30 == 2021.01.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -140 K | 207 K | 245 K | 336 K
+840030016: 2020.12.04 15:30 == 2020.12.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 245 K | 528 K | 638 K | 610 K
+840030016: 2020.11.06 15:30 == 2020.11.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 638 K | -76324 K | 661 K | 672 K
-840030016: 2020.10.02 16:30 != 2020.10.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 661 K | 78356 K | 1371 K | 1489 K
+840030016: 2020.09.04 15:30 == 2020.09.04 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 1371 K | -74433 K | 1763 K | 1734 K
+840030016: 2020.08.07 15:30 == 2020.08.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 1763 K | 4511 K | 4800 K | 4791 K
+840030016: 2020.07.02 15:30 == 2020.07.02 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 4800 K | -12034 K | 2509 K | 2699 K
+840030016: 2020.06.05 15:30 == 2020.06.05 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 2509 K | -10000 K | -20500 K | -20687 K
+840030016: 2020.05.08 15:30 == 2020.05.08 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -20500 K | 139 K | -701 K | -870 K
+840030016: 2020.04.03 15:30 == 2020.04.03 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | -701 K | 163 K | 273 K | 275 K
+840030016: 2020.03.06 15:30 == 2020.03.06 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 273 K | 161 K | 225 K | 273 K
+840030016: 2020.02.07 15:30 == 2020.02.07 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 225 K | 161 K | 145 K | 147 K
+840030016: 2020.01.10 15:30 == 2020.01.10 15:30 USD 3 Nonfarm Payrolls (nonfarm-payrolls), United States (US) | 145 K | 168 K | 266 K | 256 K


It will be necessary to check the correctness during the autumn Europe/USA unsynchronisation.

Now you can use the calendar in backtests (the sample EA in the delivery has been updated).


ZY I recommend you to look at the works of this author.

amrali
amrali
  • www.mql5.com
Trader's profile
 
  static int TimeServerGMTOffset( void )
  {
    MqlCalendarValue Value[1];

    ::CalendarValueHistoryByEvent(840030016, Value, D'2023.09.01', D'2023.09.02');

    // EVENT::CorrectTime(Value[0].time);

    return((-3 + (24 - DST::GetHour(Value[0].time - 31 * HOUR / 2)) % 24) * HOUR);
  }

I have a bad feeling about the correctness of this function.

Using limits from calculus: the output range for (x % 24) is 0 to 23, so the output range of the function is -3 to 20. therefore a server of -5 cannot be represented.

 
amrali #:

I have a bad feeling about the correctness of this function.

Using limits from calculus: the output range for (x % 24) is 0 to 23, so the output range of the function is -3 to 20. therefore a server of -5 cannot be represented.

You are right, thank you.

 

subtract directly from 12:30 (instead of -3 + 31*/2):

int TimeServerGMTOffset(void)
  {
   MqlCalendarValue Value[1];

   ::CalendarValueHistoryByEvent(840030016, Value, D'2023.09.01', D'2023.09.02');

   return((int)(D'2023.09.01 12:30' - Value[0].time));
  }