//+------------------------------------------------------------------+ //| news.mq5 | //| Copyright 2000-2026, MetaQuotes Ltd. | //| www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2000-2026, MetaQuotes Ltd." #property link "https://www.mql5.com" //--- #property script_show_inputs //--- input string symbol = "EURUSD"; // Market symbol for analysis input datetime from_t = D'2025.10.15'; // Start of quotes analysis time interval input datetime to_t = D'2026.04.15'; // End of quotes analysis time interval input ENUM_TIMEFRAMES tf = PERIOD_M5; // Time frame input string nsource = "US"; // News source input double ntau = 3000.0; // Time normalization parameter //--- #include "EconometricsM.mqh" // Header file with regression_Newey_West() function //--- //+------------------------------------------------------------------+ //| to get full list events ids for country use events2file.mq5 | //+------------------------------------------------------------------+ ulong events_ids[]= {840010007,840020001,840030006,840030015,840050014}; //--- void OnStart() { //--- quotes downloading MqlRates rates[]; int n_rates = CopyRates(symbol, tf, from_t, to_t, rates); PrintFormat("Number of downloaded quotes for symbol %s: %d", symbol, n_rates); if(n_rates<3) return; //--- Data set creation ulong n=(ulong)n_rates; datetime ntime[]; news_time(from_t-24*60*60,to_t+24*60*60,nsource,events_ids,ntime); if(ArraySize(ntime)<1) {Print("No news"); return;} Print(ArraySize(ntime)," news"); vector y(n); matrix X=matrix::Ones(n,2); for(ulong i=0;i0) ArraySort(ntime); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| function for time normalization | //+------------------------------------------------------------------+ double tnorm(datetime t) { double dt=t/ntau; return MathExp(-dt*dt); } //+------------------------------------------------------------------+