changing indicator colour

 

Hi

Pls. help fix this code which I expected to change my custom indicator color.


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_SOLID
#property indicator_color1 clrRed, clrBlue

double iBuf[];   

double iBuf_colour[];


int OnInit()
  {
   SetIndexBuffer(0,iBuf,INDICATOR_DATA);
   SetIndexBuffer(1, iBuf_colour,INDICATOR_COLOR_INDEX);
  
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);   // for dynamic array
   ArraySetAsSeries(iBuf, true);

   return(0);
  }


int OnCalculate(...

   for(int x = 0; x < ArraySize(itemp); x++)
   {
      iBuf[x] = itemp[x];
      if(x>6) iBuf_colour[x]=1;
      else iBuf_colour[x]=0;
   }

 
samjesse:

Hi

Pls. help fix this code which I expected to change my custom indicator color.

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_SOLID
#property indicator_color1 clrRed, clrBlue

...

To plot a multi-colored line, use the DRAW_COLOR_LINE drawing style.

#property indicator_type1 DRAW_COLOR_LINE

or the alternative

PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);

 

Reason: