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

 
Zaldy :


해당 코드는 값을 제공할 수 있지만 올바른 값을 제공하지는 않습니다.

내 이전 게시물을 참조하십시오

 
GumRai :


해당 코드는 값을 제공할 수 있지만 올바른 값을 제공하지는 않습니다.

내 이전 게시물을 참조하십시오

안녕하세요 Gumrai, 귀하의 코드와 여기에 첨부한 Qjol 매직 코드를 컴파일했습니다. qjol 코드가 없으면 플롯의 모양이 숫자 7과 같지만 qjol 코드를 추가하면 더 잘 작동합니다. 이미지에서 볼 수 있듯이 값이 -1로 떨어졌습니다. 플롯은 여기에서 이전 이미지와 모양이 같지만 값이 다릅니다. 이를 개선할 수 있는 방법을 조언해 주십시오. 감사해요.
 
#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(Symbol(), PERIOD_D1, Time[iCht]); 
    Buf_0[iCht] = EMPTY;  //  <<<<<<<<<<<< This is the magic code that gjol inserted and it worked.      
      //----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]++;
         } 
         }
         }
//--------------------------------------------------------------------
   return(0);// 
  }
//--------------------------------------------------------------------
 
GumRai :


해당 코드는 값을 제공할 수 있지만 올바른 값을 제공하지는 않습니다.

내 이전 게시물을 참조하십시오


안녕하세요 검라이님

이를 개선할 수 있는 최선의 방법을 알려주세요. 감사해요.

 
Zaldy :


안녕하세요 검라이님

이를 개선할 수 있는 최선의 방법을 알려주세요. 감사해요.


내 제안을 이미 구현한 것 같습니다.

코드에서 buffer[0]이 계산되지 않기 때문에 indi 라인은 0으로 떨어집니다. 이 값을 0에서 시작하여 날이 갈수록 증가할지 아니면 단순히 buffer[0] == buffer[1]로 만들어 더 깔끔하게 보이게 할지 결정해야 합니다.

 
내 지표를 코딩하는 데 큰 도움을 준 WHRoeder, qjol 및 GumRai에게 감사합니다.
 
GumRai :


내 제안을 이미 구현한 것 같습니다.

코드에서 buffer[0]이 계산되지 않기 때문에 indi 라인은 0으로 떨어집니다. 이 값을 0에서 시작하여 날이 갈수록 증가할지 아니면 단순히 buffer[0] == buffer[1]로 만들어 더 깔끔하게 보이게 할지 결정해야 합니다.


안녕하세요 GumRai, 0에서 시작하여 하루가 진행됨에 따라 증가하도록 코딩하려면 어떻게 해야 합니까? 도와주세요. 감사해요.
 
Zaldy :

안녕하세요 GumRai, 0에서 시작하여 하루가 진행됨에 따라 증가하도록 코딩하려면 어떻게 해야 합니까? 도와주세요. 감사해요.


귀하의 코드를 일부 변경했습니다



 int start()                         // Special function start()
  {
  
  
   int   i, iCht, Counted_bars, limit, iD1, iM1Beg, iM1End, counter ; 
   datetime daystarttime, nextday ;   
   double hM1, lM1, openD1 ; 
//--------------------------------------------------------------------
  Counted_bars= IndicatorCounted (); // Number of counted bars
  limit = Bars - 1 - Counted_bars;
   if (limit > Bars - 100 )   
      limit = Bars - 100 ;
   for (iCht = limit; iCht >= 0 ; iCht--){ // Chart bars
      iD1 = iBarShift ( Symbol (), PERIOD_D1 , Time [iCht]); //---Barshift on daily chart
      daystarttime = iTime ( Symbol (), PERIOD_D1 ,iD1); //--Find datetime value for start of the day      
      openD1 = iOpen ( Symbol (), PERIOD_D1 , iD1);
      
       //----find BarShift of daystarttime on current chart and take the nearest following bar if it doesn't exist
      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 )  //-- Change to iD1>=0 to show running total for the current day
         {
         nextday = iTime ( Symbol (), PERIOD_D1 ,iD1- 1 );
         iM1End = iBarShift ( Symbol (), PERIOD_M1 ,nextday- 1 , true );
         if (iM1End< 0 )         
            iM1End = iBarShift ( Symbol (), PERIOD_M1 ,nextday, false );
       
         counter = 0 ;
         for (i= iM1Beg; i >= iM1End; i--){
            hM1 = iHigh ( Symbol (), PERIOD_M1 , i);
            lM1 =   iLow ( Symbol (), PERIOD_M1 , i);
             // count Bars of M1 Period that crisscross Open price of D1 Period 
             if ( hM1 >= openD1 && openD1 >= lM1)
               counter++ ;
         }
         Buf_0[iCht] = counter; 
         }
         }
//--------------------------------------------------------------------
   return ( 0 ); // 
  }
//--------------------------------------------------------------------
//+------------------------------------------------------------------+

이것은 당신이 원하는 것을해야합니다

이대로는 오늘의 가치를 주지 않는다

강조 표시된 텍스트와 같이 변경하면 0에서 시작하여 하루가 진행됨에 따라 증가하는 오늘 값이 포함되어야 합니다.

 

줄거리가 여기에서 불완전한 이유. 2014년 1월 이전에는 채워지지 않습니다. 문제를 알려주십시오. 이 차트는 WHRoeder 코드를 사용하여 수행되었지만 GumRai에서 제안한 차트도 동일한 중단된 플롯을 제공합니다.

 
그 날짜 이전에 M1 데이터가 없기 때문에
사유: