D1 기간의 시가를 교차하는 M1 기간의 막대를 계산하는 지표 - 페이지 2

 
 
안녕하세요 WHRoeder님, 표시기를 컴파일하고 여기에 차트 이미지를 첨부했습니다. 빨간색 표시선은 위쪽에 직선을 형성하고 Bar0에 떨어집니다. 여기에 최신 코드를 첨부하여 표시기가 십자형 M1의 값을 표시할 수 있도록 코드를 개선할 부분을 친절하게 조언합니다. 미리 감사드립니다.
 #property indicator_separate_window      // Indicator is drawn in the main window
#property indicator_buffers 1        // Number of buffers
#property indicator_color1 Red     // Color of the 1st line

 
double Buf_0[];             // Declaring indicator arrays
//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].
//--------------------------------------------------------------------
int init()                           // Special function init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer ( 0 ,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle ( 0 , DRAW_LINE , STYLE_SOLID , 2 ); // Line style
//--------------------------------------------------------------------
 //  SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
   //SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Line style
//--------------------------------------------------------------------
   return ( 0 );                           // Exit the special funct.init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
  
  
     int   i= 0 , iCht, Counted_bars; 
      
   
//--------------------------------------------------------------------
  Counted_bars= IndicatorCounted (); // Number of counted bars
   for (iCht = Bars - 1 - Counted_bars; iCht >= 0 ; iCht--){ // Chart bars
       int       iD1    = iBarShift ( NULL , PERIOD_D1 , Time [iCht]);
       double    openD1 = iOpen ( NULL , PERIOD_D1 , iD1);
       int       iM1Beg = iBarShift ( NULL , PERIOD_M1 , Time [iCht]),
               iM1End = - 1 ;
       if (iCht > 0 ) iM1End = iBarShift ( NULL , PERIOD_M1 , Time [iCht- 1 ]);
       for (Buf_0[i] = 0 ; iM1Beg > iM1End; iM1Beg--){
         double hM1 = iHigh ( NULL , PERIOD_M1 , iM1Beg),
                lM1 =   iLow ( NULL , PERIOD_M1 , iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period 
         if ( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++; 
     }
  }   
//--------------------------------------------------------------------
   return ( 0 );                           // Exit the special funct. start()
  }
//--------------------------------------------------------------------
 
 
Zaldy : 위쪽에 직선이 있고 Bar0에서 떨어집니다.
M1 이력이 있습니까?
 
WHRoeder :
M1 이력이 있습니까?


네, 있어요.
 
#property indicator_separate_window      // Indicator is drawn in the main window
#property indicator_buffers 1        // Number of buffers
#property indicator_color1 Red     // Color of the 1st line

 
double Buf_0[];             // Declaring indicator arrays
//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].
//--------------------------------------------------------------------
int init()                           // Special function init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer ( 0 ,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle ( 0 , DRAW_LINE , STYLE_SOLID , 2 ); // Line style
//--------------------------------------------------------------------
 //  SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
   //SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Line style
//--------------------------------------------------------------------
   return ( 0 );                           // Exit the special funct.init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
  
  
     int   i= 0 , iCht, Counted_bars; 
      
   
//--------------------------------------------------------------------
  Counted_bars= IndicatorCounted (); // Number of counted bars
   for (iCht = Bars - 1 - Counted_bars; iCht >= 0 ; iCht--){ // Chart bars
       int       iD1    = iBarShift ( NULL , PERIOD_D1 , Time [iCht]);
       double    openD1 = iOpen ( NULL , PERIOD_D1 , iD1);
       int       iM1Beg = iBarShift ( NULL , PERIOD_M1 , Time [iCht]),
               iM1End = - 1 ;
       if (iCht > 0 ) iM1End = iBarShift ( NULL , PERIOD_M1 , Time [iCht- 1 ]);
       for (Buf_0[i] = 0 ; iM1Beg > iM1End; iM1Beg--){
         double hM1 = iHigh ( NULL , PERIOD_M1 , iM1Beg),
                lM1 =   iLow ( NULL , PERIOD_M1 , iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period 
         if ( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++; 
     }
  }   
//--------------------------------------------------------------------
   return ( 0 );                           // Exit the special funct. start()
  }
//--------------------------------------------------------------------
 

강조 표시된 코드 라인은 인디가 일일 차트에 첨부된 경우에만 올바른 이동을 제공합니다.

이전 포스팅에서 이미 말했듯이

" 그래서 D1 양초를 열려면 날짜/시간 값이 필요합니다 . 할 수 있습니까?"

 
GumRai :

강조 표시된 코드 라인은 인디가 일일 차트에 첨부된 경우에만 올바른 이동을 제공합니다.

이전 포스팅에서 이미 말했듯이

" 그래서 D1 양초를 열려면 날짜/시간 값이 필요합니다 . 할 수 있습니까?"


안녕하세요 GumRai님, 여러 번 시도했지만 컴파일조차 할 수 없었습니다. 제 이해 범위를 벗어났습니다. 가장 좋은 방법은 누군가가 나에게 어떻게 배울 수 있는지 보여줄 수 있는 것입니다. 예가 있으면 빠르게 배울 수 있습니다. 현재 지표는 Open[1] 가격을 교차하는 Bar1 내의 M1 막대를 계산하고 있습니다. 그러나 계산은 거기에서 멈추고 그래프를 완성하기 위해 진행되지 않습니다. 표시기를 EA에 연결하려고 했지만 백 테스트 시 EA에서도 신호를 보낼 수 없습니다. 이 표시기를 영원히 완성할 몇 가지 코드를 보여주세요. 고맙습니다.
 
Buf_0[iCht] = EMPTY;
 
Zaldy :

안녕하세요 GumRai님, 여러 번 시도했지만 컴파일조차 할 수 없었습니다. 제 이해 범위를 벗어났습니다. 가장 좋은 방법은 누군가가 나에게 어떻게 배울 수 있는지 보여줄 수 있는 것입니다. 예가 있으면 빠르게 배울 수 있습니다. 현재 지표는 Open[1] 가격을 교차하는 Bar1 내의 M1 막대를 계산하고 있습니다. 그러나 계산은 거기에서 멈추고 그래프를 완성하기 위해 진행되지 않습니다. 표시기를 EA에 연결하려고 했지만 백 테스트 시 EA에서도 신호를 보낼 수 없습니다. 이 표시기를 영원히 완성할 몇 가지 코드를 보여주세요. 고맙습니다.


컴파일되거나 테스트되지 않았지만 도움이 될 수 있습니다.

Counted_bars= IndicatorCounted (); // Number of counted bars
   for (iCht = Bars - 1 - Counted_bars; iCht >= 0 ; iCht--){ // Chart bars
       int       iD1    = iBarShift ( Symbol (), PERIOD_D1 , Time [iCht]); 
      
       //----find the datetime of iD1. ie the Time[]
       datetime daystarttime = iTime ( Symbol (), PERIOD_D1 ,iD1);
      
       double    openD1 = iOpen ( Symbol (), PERIOD_D1 , iD1);
      
       //----find BarShift of daystarttime on current chart and take the nearest following bar if it doesn't exist
       int iM1Beg = iBarShift ( Symbol (), PERIOD_M1 ,daystarttime, true );
       if (iM1Beg< 0 )
         iM1Beg = iBarShift ( Symbol (), PERIOD_M1 ,daystarttime, false )+ 1 ;
      
       //----find BarShift for end of day on current chart and take the nearest following bar if it doesn't exist
       if (iD1> 0 )
         {
         datetime nextday = iTime ( Symbol (), PERIOD_D1 ,iD1- 1 );
         int iM1End = iBarShift ( Symbol (), PERIOD_M1 ,nextday- 1 , true );
         if (iM1End< 0 )
            iM1End = iBarShift ( Symbol (), PERIOD_M1 ,nextday, false );
      
               
      
         for (Buf_0[i] = 0 ; iM1Beg > iM1End; iM1Beg--){
                 double hM1 = iHigh ( Symbol (), PERIOD_M1 , iM1Beg),
                lM1 =   iLow ( Symbol (), PERIOD_M1 , iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period 
         if ( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++;
         } 
         }
 
qjol :


Buf_0[iCht] = EMPTY; WHRoeder 코드에 삽입하고 어떻게든 표시기가 작동했습니다. 이미지와 최신 컴파일 코드를 확인하십시오. 그러나 내 EA에 링크했을 때 마치 술 취한 사람이 우유를 뱉는 것처럼 계속 로드 및 언로드되었습니다. 동일한 EA에 연결된 다른 지표는 잘 작동했습니다. 이것은 내가받은 메시지입니다 :

2014.02.25 17:17:08.806 2014.01.02 07:48 커스텀 인디케이터 MamaMaryII EURPLN,Daily: 제거됨

2014.02.25 17:17:08.799 2014.01.02 07:48 사용자 지정 표시 MamaMaryII EURPLN,매일: 성공적으로 로드됨

2014.02.25 17:17:08.794 2014.01.02 07:48 커스텀 인디케이터 MamaMaryII EURPLN,Daily: 제거됨

2014.02.25 17:17:08.787 2014.01.02 07:48 사용자 지정 표시 MamaMaryII EURPLN,매일: 성공적으로 로드됨

2014.02.25 17:17:08.783 2014.01.02 07:48 커스텀 인디케이터 MamaMaryII EURPLN,Daily: 제거됨

2014.02.25 17:17:08.774 2014.01.02 07:48 사용자 지정 표시 MamaMaryII EURPLN,매일: 성공적으로 로드됨

2014.02.25 17:17:08.768 2014.01.02 07:48 커스텀 인디케이터 MamaMaryII EURPLN,Daily: 제거됨

무엇이 잘못되었는지 알려주세요. 감사해요. 차트에 첨부된 사용자 지정 지표
 
#property indicator_separate_window    // Indicator is drawn in the main window
#property indicator_buffers 1       // Number of buffers
#property indicator_color1 Red     // Color of the 1st line
//#property indicator_color2 Yellow      // Color of the 2nd line
 
extern int Multiplier=2; 
double Buf_0[];// Buf_1[];             // Declaring indicator arrays
//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].
//--------------------------------------------------------------------
int init()                          // Special function init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style
//--------------------------------------------------------------------
//   SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
//   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2);// Line style
//--------------------------------------------------------------------
   return(0);                          // Exit the special funct.init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
  
  
     int  i=0, iCht, Counted_bars; 
      
   
//--------------------------------------------------------------------
  Counted_bars=IndicatorCounted(); // Number of counted bars
  
   for(iCht = Bars - 1 - Counted_bars; iCht >= 0; iCht--){ // Chart bars
  
      int      iD1    = iBarShift(NULL, PERIOD_D1, Time[iCht]);
      double   openD1 = iOpen(NULL, PERIOD_D1, iD1);
      int      iM1Beg = iBarShift(NULL, PERIOD_M1, Time[iCht]),
               iM1End = -1;
      if(iCht > 0) iM1End = iBarShift(NULL, PERIOD_M1, Time[iCht-1]);
   Buf_0[iCht] = EMPTY;  //  <<<<<<<<<<<< This is the magic code that gjol inserted and it worked.    
      for(Buf_0[i] = 0; iM1Beg > iM1End; iM1Beg--){
         double hM1 = iHigh(NULL, PERIOD_M1, iM1Beg),
                lM1 =  iLow(NULL, PERIOD_M1, iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period 
        if( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++; 
       // Buf_1[iCht]= Multiplier*Buf_0[iCht];
     }
  }   
//--------------------------------------------------------------------
   return(0);// 
  }
//--------------------------------------------------------------------