//+------------------------------------------------------------------+ //| MyExpertAdvisor.mq5 | //| by XYZ | //| https://www.example.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright XYZ" #property link "https://www.example.com/" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- specify the number of bars to retrieve int limit = 1440; //--- create an array to store the closing prices MqlRates rates[]; ArraySetAsSeries(rates, true); //--- retrieve the closing prices int copied = CopyRates(_Symbol, PERIOD_M1, 0, limit, rates); Print("Copied Values:",copied); if (copied == 0) { Print("Error copying rates data: ", GetLastError()); return INIT_FAILED; } //--- calculate the price differences double diff[]; ArrayResize(diff, limit-1); for (int i=0; i diff[i+1]); if (rise && prev_rise) { count++; } else { rises[count]++; count = 0; } prev_rise = rise; if (fall && prev_fall) { count++; } else { falls[count]++; count = 0; } prev_fall = fall; } rises[count]++; falls[count]++; //--- output the results for (int i=2; i<=10; i++) { PrintFormat("Series of %d consecutive rises: %d", i, rises[i]); PrintFormat("Series of %d consecutive falls: %d", i, falls[i]); } return INIT_SUCCEEDED; }