//properties #property version "1.05" #property script_show_inputs //definitions #define IND_PER_SYMB 500 #define TIMEFRAME PERIOD_M5 //inputs input bool MarketWatchOnly = false; //Select symbols from Market Watch only input bool LoadSymbol = true; //Load symbol before initializing Indicators input bool UseCustomMA = true; //Use Custom MA //+------------------------------------------------------------------+ //| main function //+------------------------------------------------------------------+ void OnStart(){ //once upon a time... Print("DemoMaxInd: started."); //fetch all total symbols int totalSymbols = SymbolsTotal(MarketWatchOnly); //dynamically declare symbolsIndicators int symbolsIndicators[][IND_PER_SYMB]; // there are 12 indicators for each symbol if (ArrayResize(symbolsIndicators,totalSymbols,0) < 0){ Print("Oops! Failed to dynamically resize 'symbolsIndicators[][12]'"); return; } //loop through all symbols for (int s=0; s0 && first_date<=start_date) return(1); //--- don't ask for load of its own data if it is an indicator if(MQL5InfoInteger(MQL5_PROGRAM_TYPE)==PROGRAM_INDICATOR && Period()==period && Symbol()==symbol) return(-4); //--- second attempt if(SeriesInfoInteger(symbol,PERIOD_M1,SERIES_TERMINAL_FIRSTDATE,first_date)) { //--- there is loaded data to build timeseries if(first_date>0){ //--- force timeseries build CopyTime(symbol,period,first_date+PeriodSeconds(period),1,times); //--- check date if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date)) if(first_date>0 && first_date<=start_date) return(2); } } //--- max bars in chart from terminal options int max_bars=TerminalInfoInteger(TERMINAL_MAXBARS); //--- load symbol history info datetime first_server_date=0; while(!SeriesInfoInteger(symbol,PERIOD_M1,SERIES_SERVER_FIRSTDATE,first_server_date) && !IsStopped()) Sleep(5); //--- fix start date for loading if(first_server_date>start_date) start_date=first_server_date; if(first_date>0 && first_date0) { if(bars>=max_bars) return(-2); //--- ask for first date if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date)) if(first_date>0 && first_date<=start_date) return(0); } //--- copying of next part forces data loading int copied=CopyTime(symbol,period,bars,100,times); if(copied>0) { //--- check for data if(times[0]<=start_date) return(0); if(bars+copied>=max_bars) return(-2); fail_cnt=0; } else { //--- no more than 100 failed attempts fail_cnt++; if(fail_cnt>=100) return(-5); Sleep(10); } } //--- stopped return(-3); }