Download MetaTrader 5

changing indicator colour

To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
samjesse
205
samjesse 2011.09.25 09:11 

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;
   }

rodesh
116
rodesh 2011.09.25 14:20  
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);

 

To add comments, please log in or register