Why doesn't this indicator get plotted on the chart?

To add comments, please log in or register
josephcom
115
josephcom  

I really can't understand why this custom indicator doesn't draw anything on my chart?


#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrOrangeRed
#property indicator_width1  1

#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrChartreuse
#property indicator_width2  1

double Buf1[], Buf2[];

int OnInit()
{
 ArraySetAsSeries(Buf1, false); // I also changed it to "true". Still nothing drawn
 SetIndexBuffer(0, Buf1);
 PlotIndexSetInteger(0, PLOT_ARROW, 241); // up
 PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0);

 ArraySetAsSeries(Buf2, false); // I also changed it to "true". Still nothing drawn
 SetIndexBuffer(1, Buf2);
 PlotIndexSetInteger(1, PLOT_ARROW, 242); // down
 PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0);

 return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {  
     for (int i=1; i<rates_total-1; i++)
     {
        Buf1[i] = 1.18592;  // just an illustration
        Buf2[i] = 1.18592;
     }

     return(rates_total);
  }

  
josephcom
115
josephcom  

OK, I myself just discovered the answer. I'd forgotten to include the following line:

#property indicator_plots 2
To add comments, please log in or register