Color changes acc to Line direction

shanki99

Well-Known Member
#1
Gurus

Plz help me out with a reference on --

How to make any line like RSI or Stoch to change its color according to its direction. My broker charts used to give out all its lines like that, be it EMAs, MACD, RSI, Stoch etc.....

Take an example of simple momentum indicator and show me how to change the color of the line as per its direction

Thanx again
 
#2
shanki99

for plotting any line like MA,RSI,StochD etc we write code as follows

Plot( EMA(C,14), "EMA", colorBlue, styleLine );

Plot( RSI(14), "RSI", colorRed, styleLine );

Plot( StochD(8,3,3), "StochD", colorGreen, styleLine);

Which plots a line with the assigned color.

For plotting Line with change of color according to direction
we have to assign color as follows

Color = IIf(EMA(C,14) > Ref(EMA(C,14),-1), colorBlue, colorRed);
Plot( EMA(C,14), "EMA", Color, styleLine);

Color = IIf(RSI(14) > Ref(RSI(14),-1), colorBlue, colorRed);
Plot( RSI(14), "RSI", Color, StyleLine);

Color = IIf(StochD(8,3,3) > Ref(StochD(8,3,3),-1) ,colorGreen, colorRed);
Plot(StochD(8,3,3), "StochD", Color, StyleLine);

like this you can change the color of line according to direction,
I have given more examples because you can easily follow

vidyasagar