// Downloaded From https://www.WiseStockTrader.com
Indicator = ParamList("Indicator", "RSI|STOCH");
C_mode    = ParamList("Color mode", "CM1|CM2");

function rcolor(r)
{
	Saturation0 = 255;
	Brightness0 = 255;
	Minr = LLV(r, BarCount);
	Maxr = HHV(r, BarCount);
	rn = (r-Minr)/(Maxr-Minr);
	if(C_mode == "CM1") {
		Hue0 = 220-int(rn*220.0);
	} else {
		rn = (rn/sqrt(1.0+rn^2))*sqrt(2);
		Hue0 = 220-int(rn*220.0);
	}
	return ColorHSB(Hue0, Saturation0, Brightness0);
}

Iperiod = Param("Indicator period", 13, 2, 50);

if(Indicator == "RSI") {
	Ivalue = RSI(Iperiod);
} else {
	Ivalue = StochD(Iperiod, 3, 3);
}

Plot(C, "Close", rcolor(Ivalue), styleCandle);