라이브러리: 히스토리로더

 

히스토리로더:

쿼리 결과 처리와 함께 모든 기록 데이터에 대한 액세스를 구성하는 다중 통화 전문가 어드바이저 기능 모듈입니다.

Author: Nikolay Kositsin

 
Automated-Trading:

히스토리로더:

저자: 니콜라이 코시친

91번째 줄에 구문 오류(H 누락)."SERIES_SYNCRONIZED"는 "SERIES_SYNCHRONIZED"가 되어야 합니다.
 
elib:
91번째 줄에 구문 오류(H 누락)."SERIES_SYNCRONIZED"는 "SERIES_SYNCHRONIZED"가 되어야 합니다.

달 아래 영원한 것은 없습니다!

//+------------------------------------------------------------------+
//| 업로드 기록 확인|
//+------------------------------------------------------------------+
int CheckLoadHistory(string symbol,ENUM_TIMEFRAMES period,datetime start_date)
  {
//----+
   datetime first_date=0;
   datetime times[100];
//--- 기호 및 마침표 확인
   if(symbol == NULL || symbol == "") symbol = Symbol();
   if(period == PERIOD_CURRENT)     period = Period();
//--- 마켓워치에서 심볼이 선택되어 있는지 확인합니다.
   if(!SymbolInfoInteger(symbol,SYMBOL_SELECT))
     {
      if(GetLastError()==ERR_MARKET_UNKNOWN_SYMBOL) return(-1);
      if(!SymbolSelect(symbol,true)) Print(__FUNCTION__,"(): 문자를 추가하지 못했습니다.",symbol,"마켓워치 창에서!!!");
     }
//--- 데이터가 있는지 확인
   SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date);
   if(first_date>0 && first_date<=start_date) return(1);
//--- 지표인 경우 자체 데이터의 로드를 요청하지 마십시오.
   if(MQL5InfoInteger(MQL5_PROGRAM_TYPE)==PROGRAM_INDICATOR && Period()==period && Symbol()==symbol)
      return(-4);
//--- 두 번째 시도
   if(SeriesInfoInteger(symbol,PERIOD_M1,SERIES_TERMINAL_FIRSTDATE,first_date))
     {
      //--- 시계열을 작성하기 위해 로드된 데이터가 있습니다.
      if(first_date>0)
        {
         //--- 강제 시계열 빌드
         CopyTime(symbol,period,first_date+PeriodSeconds(period),1,times);
         //--- 날짜 확인
         if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date))
            if(first_date>0 && first_date<=start_date) return(2);
        }
     }
//--- 터미널 옵션에서 차트의 최대 막대
   int max_bars=TerminalInfoInteger(TERMINAL_MAXBARS);
//--- 심볼 히스토리 정보 로드
   datetime first_server_date=0;
   while(!SeriesInfoInteger(symbol,PERIOD_M1,SERIES_SERVER_FIRSTDATE,first_server_date) && !IsStopped())
      Sleep(5);
//--- 로딩 시작 날짜 수정
   if(first_server_date>start_date) start_date=first_server_date;
   if(first_date>0 && first_date<first_server_date)
      Print(__FUNCTION__,"(): Warning: first server date ",first_server_date," for ",symbol,
            " does not match to first series date ",first_date);
//--- 단계별 데이터 로드
   int fail_cnt=0;
   while(!IsStopped())
     {
      //--- 시계열 빌드 대기
      while(!SeriesInfoInteger(symbol,period,SERIES_SYNCHRONIZED) && !IsStopped())
         Sleep(5);
      //--- 빌드된 바 요청
      int bars=Bars(symbol,period);
      if(bars>0)
        {
         if(bars>=max_bars) return(-2);
         //--- 첫 데이트 신청하기
         if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date))
            if(first_date>0 && first_date<=start_date) return(0);
        }
      //--- 다음 부분을 복사하면 데이터가 강제로 로드됩니다.
      int copied=CopyTime(symbol,period,bars,100,times);
      if(copied>0)
        {
         //--- 데이터 확인
         if(times[0]<=start_date) return(0);
         if(bars+copied>=max_bars) return(-2);
         fail_cnt=0;
        }
      else
        {
         //--- 시도 실패 횟수 100회 이하
         fail_cnt++;
         if(fail_cnt>=100) return(-5);
         Sleep(10);
        }
     }
//----+stopped
   return(-3);
  }
//+------------------------------------------------------------------+
 

작동하지 않습니다, 첫 번째 문자에서 죽습니다....

다음은 코드입니다.

//+------------------------------------------------------------------+ 
//|TestLoadHistory.mq5 | 
//| 저작권 2009, MetaQuotes Software Corp. 
//| https://www.mql5.com | 
//+------------------------------------------------------------------+ 
#property copyright "2009, MetaQuotes Software Corp." 
#property link      "https://www.mql5.com" 
#property version   "1.02" 
#property script_show_inputs 

//--- 입력 매개변수 

//+------------------------------------------------------------------+ 
//| 스크립트 프로그램 시작 기능| 
//+------------------------------------------------------------------+ 
void OnStart()
  {


   int      all_symbols=SymbolsTotal(false);   string  sym_name="";
   Print("Load symbols ",all_symbols);

   for(int k=0;k<all_symbols;k++)
      if((sym_name=SymbolName(k,false))!="")
        {
         SymbolSelect(sym_name,true);

         Print(k," Symbol name ",sym_name);

datetime time= (TimeCurrent()-60*60*24*5);


         int res=CheckLoadHistory(sym_name,PERIOD_M1,time);

         switch(res)
           {
            case -1 : Print("Unknown symbol ",sym_name);             break;
            case -2 : Print("Requested bars more than max bars in chart ",sym_name); break;
            case -3 : Print("Program was stopped ",sym_name);                        break;
            case -4 : Print("Indicator shouldn't load its own data ",sym_name);      break;
            case -5 : Print("Load failed ",sym_name);                                break;
            case  0 : Print("Loaded OK ",sym_name);                                  break;
            case  1 : Print("Loaded previously ",sym_name);                          break;
            case  2 : Print("Loaded previously and built ",sym_name);                break;
            default : Print("Unknown result ",sym_name);
           }

         datetime first_date;
         SeriesInfoInteger(sym_name,PERIOD_M1,SERIES_FIRSTDATE,first_date);
         int bars=Bars(sym_name,PERIOD_M1);
         Print("First date ",first_date," - ",bars," bars");
       }
//--- 

//--- 
  }
//+------------------------------------------------------------------+
//| 업로드 기록 확인|
//+------------------------------------------------------------------+
int CheckLoadHistory(string symbol,ENUM_TIMEFRAMES period,datetime start_date)
  {
//----+
   datetime first_date=0;
   datetime times[100];
//--- 기호 및 마침표 확인
   if(symbol == NULL || symbol == "") symbol = Symbol();
   if(period == PERIOD_CURRENT)     period = Period();
//--- 마켓워치에서 심볼이 선택되어 있는지 확인합니다.
   if(!SymbolInfoInteger(symbol,SYMBOL_SELECT))
     {
      if(GetLastError()==ERR_MARKET_UNKNOWN_SYMBOL) return(-1);
      if(!SymbolSelect(symbol,true)) Print(__FUNCTION__,"(): 문자를 추가하지 못했습니다.",symbol,"마켓워치 창에서!!!");
     }
//--- 데이터가 있는지 확인
   SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date);
   if(first_date>0 && first_date<=start_date) return(1);
//--- 지표인 경우 자체 데이터의 로드를 요청하지 마십시오.
   if(MQL5InfoInteger(MQL5_PROGRAM_TYPE)==PROGRAM_INDICATOR && Period()==period && Symbol()==symbol)
      return(-4);
//--- 두 번째 시도
   if(SeriesInfoInteger(symbol,PERIOD_M1,SERIES_TERMINAL_FIRSTDATE,first_date))
     {
      //--- 시계열을 작성하기 위해 로드된 데이터가 있습니다.
      if(first_date>0)
        {
         //--- 강제 시계열 빌드
         CopyTime(symbol,period,first_date+PeriodSeconds(period),1,times);
         //--- 날짜 확인
         if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date))
            if(first_date>0 && first_date<=start_date) return(2);
        }
     }
//--- 터미널 옵션에서 차트의 최대 막대
   int max_bars=TerminalInfoInteger(TERMINAL_MAXBARS);
//--- 심볼 히스토리 정보 로드
   datetime first_server_date=0;
   while(!SeriesInfoInteger(symbol,PERIOD_M1,SERIES_SERVER_FIRSTDATE,first_server_date) && !IsStopped())
      Sleep(5);
//--- 로딩 시작 날짜 수정
   if(first_server_date>start_date) start_date=first_server_date;
   if(first_date>0 && first_date<first_server_date)
      Print(__FUNCTION__,"(): Warning: first server date ",first_server_date," for ",symbol,
            " does not match to first series date ",first_date);
//--- 단계별 데이터 로드
   int fail_cnt=0;
   while(!IsStopped())
     {
      //--- 시계열 빌드 대기
      while(!SeriesInfoInteger(symbol,period,SERIES_SYNCHRONIZED) && !IsStopped())
         Sleep(5);
      //--- 빌드된 바 요청
      int bars=Bars(symbol,period);
      if(bars>0)
        {
         if(bars>=max_bars) return(-2);
         //--- 첫 데이트 신청하기
         if(SeriesInfoInteger(symbol,period,SERIES_FIRSTDATE,first_date))
            if(first_date>0 && first_date<=start_date) return(0);
        }
      //--- 다음 부분을 복사하면 데이터가 강제로 로드됩니다.
      int copied=CopyTime(symbol,period,bars,100,times);
      if(copied>0)
        {
         //--- 데이터 확인
         if(times[0]<=start_date) return(0);
         if(bars+copied>=max_bars) return(-2);
         fail_cnt=0;
        }
      else
        {
         //--- 시도 실패 횟수 100회 이하
         fail_cnt++;
         if(fail_cnt>=100) return(-5);
         Sleep(10);
        }
     }
//----+stopped
   return(-3);
  }
//+------------------------------------------------------------------+

그리고 여기서 죽습니다.

while(!SeriesInfoInteger(symbol,period,SERIES_SYNCHRONIZED) && !IsStopped())
 

안녕하세요 Nikolay

Historyloader.mqh에는 다음과 같은 함수만 있습니다.

int CheckLoadHistory(문자열 symbol,ENUM_TIMEFRAMES period,datetime start_date)

의 함수만 있고 언급된 Loadhistory() 함수는 없습니다.
 
Nikolay Kositsin:

달 아래 영원한 것은 없습니다!

정말 고마워요!