Probably a very stupid question (solved) - page 2

 
Ok this
onewithzachy:

My apology for writing "No" that long, I hope you don't get the wrong idea, ... and it's not stupid question like I've told you before.

That could be possible case, however in my case, sometime I don't get that color back on chart so I have to write them as extern input.

Okay this is not working xD Something is missing :P Here's the code:

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1

//-------------------------------
// External variables
//-------------------------------
extern int AvPeriod = 2;
extern color Up = DodgerBlue;
extern color Down = Red;
extern color Line = Teal;

//-------------------------------
// Buffers
//-------------------------------

double FextMapBuffer1[];
double FextMapBuffer2[];
double FextMapBuffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
{
   // Total buffers
   IndicatorBuffers(5);
   
   // Visible buffers
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, indicator_width1, Up);
   SetIndexBuffer(0, FextMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, indicator_width2, Down);
   SetIndexBuffer(1, FextMapBuffer2);
   SetIndexStyle(3,DRAW_LINE, 0, indicator_width3, Line);
   SetIndexBuffer(2,FextMapBuffer3);    
   
   // Bla bla bla
}

And all buffers are displayed black when the indicator is loaded, not default colors =(

 
flaab:
Ok this

Okay this is not working xD Something is missing :P Here's the code:

And all buffers are displayed black when the indicator is loaded, not default colors =(


Ok I now what it is, for some reason it works fine without passing the two last parameters of SetIndexStyle().
 

This is some properties

#property indicator_color1 White
#property indicator_width1 1

Property is automatically created when we create Custom Indicator. Property is not variable.

The SetIndexStyle() function has 5 parameters in it, and all 5 of them need a value or a variable,

void SetIndexStyle( int index, int type, int style=EMPTY, int width=EMPTY, color clr=CLR_NONE) 

the last 3 parameter of SetIndexStyle() already has value

int style=EMPTY, int width=EMPTY, color clr=CLR_NONE 

So, It is OK to write SetIndexStyle() with just it's first 2 parameters, like this

SetIndexStyle( 0, DRAW_HISTOGRAM);

However if we want to write SetIndexStyle() with more than 2 of it's parameter, we need to put value, or a variable. and never property to it's other 3 parameters. In your case, since you only want to change it's color, it will be like this :

extern color My_Cool_1 = Orange;

SetIndexStyle(0,DRAW_HISTOGRAM, 0, 0, My_Cool_1 );

// or you can do this ...
SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, EMPTY, My_Cool_1 );

// or you can do this ...
SetIndexStyle(0,DRAW_HISTOGRAM, 1, 1, My_Cool_1 );

// or you can do this ...
SetIndexStyle(0,DRAW_HISTOGRAM, 1, 0, My_Cool_1 );

Whatever it is, put a value or a variable in it.

:)