#RevesedEngineeredRSI_Upper_Lowerbands mod by LAR
input length = 11;
input price = close;
input rsiValue = 65.0;
input smoothingType = {default Wilders, EMA};
def coeff = rsiValue / (100 - rsiValue);
def chg = price - price[1];
def diff;
switch (smoothingType) {
case Wilders:
diff = (length - 1) * (WildersAverage(Max(-chg, 0), length) * coeff - WildersAverage(Max(chg, 0), length));
case EMA:
diff = (length - 1) * (ExpAverage(Max(-chg, 0), length) * coeff - ExpAverage(Max(chg, 0), length)) / 2;
}
def value = price + if diff >= 0 then diff else diff / coeff;
plot RevEngRSI = compoundValue(1, value[1], Double.NaN);
RevEngRSI.SetDefaultColor(Color.BLACK);
input rsiValue1 = 35.0;
def coeff1 = rsiValue1 / (100 - rsiValue1);
def chg1 = price - price[1];
def diff1;
switch (smoothingType) {
case Wilders:
diff1 = (length - 1) * (WildersAverage(Max(-chg1, 0), length) * coeff1 - WildersAverage(Max(chg1, 0), length));
case EMA:
diff1 = (length - 1) * (ExpAverage(Max(-chg1, 0), length) * coeff1 - ExpAverage(Max(chg1, 0), length)) / 2;
}
def value1 = price + if diff1 >= 0 then diff1 else diff1 / coeff1;
plot RevEngRSI1 = compoundValue(1, value1[1], Double.NaN);
RevEngRSI1.SetDefaultColor(Color.BLACK);
input rsiValue2 = 50.0;
input smoothingType2 = {default Wilders, EMA};
def coeff2 = rsiValue2 / (100 - rsiValue2);
def chg2 = price - price[1];
def diff2;
switch (smoothingType2) {
case Wilders:
diff2 = (length - 1) * (WildersAverage(Max(-chg2, 0), length) * coeff2 - WildersAverage(Max(chg2, 0), length));
case EMA:
diff2 = (length - 1) * (ExpAverage(Max(-chg2, 0), length) * coeff2 - ExpAverage(Max(chg2, 0), length)) / 2;
}
def value2 = price + if diff2 >= 0 then diff2 else diff2 / coeff2;
plot RevEngRSI2 = compoundValue(1, value2[1], Double.NaN);
RevEngRSI2.SetDefaultColor(Color.BLACK);
addcloud(revEngRSI,revEngRSI2,color.green,color.green);
AddCloud(revEngRSI2, data2 = RevEngRSI1, color2 = Color.red, color1 = Color.red);