There is a new indicator posted in the NinjaScript File Sharing section that colors the bars based on indicator values.
I was playing around with it and found that it doesn't work for charts where the stock or index is above approx 100.
Wonder if there is any simple solution to this?
protected override void OnBarUpdate()
{
// Opaque colors (alpha value defaults to 255 -- max value).
Color red = Color.FromArgb(255, 0, 0);
Color green = Color.FromArgb(0, 255, 0);
Color blue = Color.FromArgb(0, 0, 255);
Color backcolor = Color.Empty;
double rsiValue = RSI(period, smooth)[0];
int rgbGreen = 0;
int rgbRed = 0;
rgbRed = (int) (255*(rsiValue)/100);
rgbGreen = 255-rgbRed;
//Print("RSI: " + rsiValue + " Green: " + rgbGreen + " Red: " + rgbRed);
backcolor = Color.FromArgb(rgbRed,rgbGreen,0);
BarColor = backcolor;
}
Comment