Simple indicator does not work. Any help greatly appreciated. Only 20 lines of code. I cannot find the error. Thanks

 

Hi Everyone.

I have tried to modify the indicator presented in the book.

All I want, is to show an arrow above every Monday, when used on the daily charts.

A very simple code, but it will not indicate anything.

Any help would be greatly appreciated. Many thanks.

#property indicator_chart_window    // Indicator is drawn in the main window
#property indicator_buffers 1       // Number of buffers
#property indicator_color1 Blue     // Color of the arrow

  double Buf_0[];             // Declaring arrays(for indicator buffers)
//--------------------------------------------------------------------
   int init()                          // Special function init()
       {  
      SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer 
      SetIndexStyle (0,DRAW_ARROW,2);// Line style  
      return;    // Exit the special funct. init()
      }
                  //--------------------------------------------------------------------
    
     int start()                         // Special function start()
   
    {  
     int i,Counted_bars;    //  --------------------------------------------------------------------  
     Counted_bars=IndicatorCounted(); // Number of counted bars 
     i=Bars-Counted_bars-1;           // Index of the first uncounted 
       while(i>=0)
          {                // Loop for uncounted bars  
        if (DayOfWeek()==1)
        Buf_0[i]=High[i];             // Value of 0 buffer on i bar  
              
        i--;                          // Calculating index of the next bar 
       }
      return;                          // Exit the special funct. start()
    }
Files:
day.mq4  2 kb
 

DayOfWeek() returns current value

Use TimeDayOfWeek(Time[i])

 
irusoh1 wrote >>

DayOfWeek() returns current value

Use TimeDayOfWeek(Time[i])

Awesome mate. Thanks very much

Reason: