how can i get the following to export the report every minute , for now i have to…
- User
how can i get the following to export the report every minute , for now i have to compile to get the report:
//+------------------------------------------------------------------+ //| ExportMultiPairsRange.mq5 | //| Export price data for multiple symbols and timeframes to ONE CSV| //+------------------------------------------------------------------+ #property strict
//--- Define your symbols string Symbols[] = { "EURUSD.Z", "GBPUSD.Z", "USDJPY.Z", "AUDUSD.Z", "EURGBP.Z", "EURJPY.Z", "GBPJPY.Z", "USDCAD.Z", "USDCHF.Z" };
//--- Define your timeframes ENUM_TIMEFRAMES TimeFrames[] = { //PERIOD_M1, //PERIOD_M5, //PERIOD_M15, //PERIOD_M30, PERIOD_H1, //PERIOD_H2, //PERIOD_H4, //PERIOD_D1, //PERIOD_W1,
// Add more if needed };
//--- Define custom date range //datetime fromDate = StringToTime("2024.01.01 00:00"); datetime fromDate = StringToTime("2025.07.10 00:00"); datetime toDate = StringToTime("2025.07.10 23:59");
//--- Output file name string outputFilename = "MultiPairExport_D1.csv";
//+------------------------------------------------------------------+ //| Export data for a given symbol/timeframe and date range | //+------------------------------------------------------------------+ void ExportSymbolTimeframeRange(int file_handle, string symbol, ENUM_TIMEFRAMES timeframe, datetime fromDate, datetime toDate) { //--- Load rates MqlRates rates[]; if (!CopyRates(symbol, timeframe, fromDate, toDate, rates)) { PrintFormat("❌ Failed to get rates for %s %s", symbol, EnumToString(timeframe)); return; }
//--- Write data rows for (int i = 0; i < ArraySize(rates); i++) { MqlRates r = rates[i]; string time_str = TimeToString(r.time, TIME_DATE | TIME_SECONDS); FileWrite(file_handle, time_str, DoubleToString(r.open, 5), DoubleToString(r.high, 5), DoubleToString(r.low, 5), DoubleToString(r.close, 5), (ulong)r.tick_volume, symbol, EnumToString(timeframe) ); } }
//+------------------------------------------------------------------+ //| Initialization Function | //+------------------------------------------------------------------+ int OnInit() { Print("🔁 Starting multi-symbol export to one file...");
//--- Open a single CSV file int file_handle = FileOpen(outputFilename, FILE_WRITE | FILE_CSV, ';'); if (file_handle == INVALID_HANDLE) { PrintFormat("❌ Failed to open file: %s", outputFilename); return INIT_FAILED; }
//--- Write header FileWrite(file_handle, "Time", "Open", "High", "Low", "Close", "Volume", "Pair", "Timeframe");
//--- Loop through symbols and timeframes for (int s = 0; s < ArraySize(Symbols); s++) { string sym = Symbols[s];
code - Assistant
- User
is the code a snippet or the full code , kindly provide the full code
- Assistant