If you like the Reverse Engineered RSI indicator, then you are in for a treat. I created a MTF with current version that shows oversold bands/clouds, with a squeeze cloud included. There is an "extreme" line that shows when RSI is over 80 or less than 20. The MTF and current version can be toggled on/off in the settings. The squeeze cloud for both current and MTF can be toggled on/off in the settings. The Colored Candles can be turned on/off. Default settings are MTF 4hr, RSI length =12, Color bars off, extreme off. Feel free to adjust these. The Green and Red Clouds represent when price is "oversold/overbought" in RSI. Yellow arrows are when price leaves these areas on the current timeframe and the magenta and cyan arrows are when price leaves the MTF area. The squeeze has two colors to measure strength. Red is mild and orange is extreme. Enjoy!
This example is on a 4 min chart showing the 4 hour oversold green cloud. Price is exiting the area. Note: cyan arrows are displayed for all of the candles that are in the 4 hour candle time frame.
In this example, on a 15 min chart, but viewing only the 4 hour version. Notice price leaving oversold area, passing through a squeeze, and pushing higher.
I noticed something interesting when trading. When price went outside the MTF cloud, it caught the low. Here is an example.
https%3A//i.imgur.com/a2OGWWn.jpg[/img]']
Shareable Link:
http://tos.mx/T1N4zwR
CODE:
This example is on a 4 min chart showing the 4 hour oversold green cloud. Price is exiting the area. Note: cyan arrows are displayed for all of the candles that are in the 4 hour candle time frame.
In this example, on a 15 min chart, but viewing only the 4 hour version. Notice price leaving oversold area, passing through a squeeze, and pushing higher.
I noticed something interesting when trading. When price went outside the MTF cloud, it caught the low. Here is an example.
https%3A//i.imgur.com/a2OGWWn.jpg[/img]']
Shareable Link:
http://tos.mx/T1N4zwR
CODE:
Code:
# "Trade In The Shade"
# MTF and Current ReverseEngineeringRSI with Bands and Squeeze
# Assembled by Chewie 9/16/2022
input aggregationPeriod = AggregationPeriod.thirty_MIN;
input MTF = yes;
input Current = yes;
input length = 12;
input rsiValue = 50.0;
input rsivaluetop = 70;
input rsivalueb = 30;
input rsivalueOB = 80;
input rsivalueOS = 20;
input smoothingType = {default Wilders, EMA};
input ColorBar = yes;
input MTFColorBar = no;
input Extreme = no;
def closeMTF = close(period = aggregationPeriod);
def price = close;
def priceMTF = closeMTF;
def coeff = rsiValue / (100 - rsiValue);
def chg = price - price[1];
def chgMTF = priceMTF - priceMTF[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 = if Current then CompoundValue(1, value[1], Double.NaN) else Double.NaN;
RevEngRSI.SetDefaultColor(CreateColor(255, 204, 0));
RevEngRSI.SetLineWeight(3);
#MTF RSI
def diffMTF;
switch (smoothingType) {
case Wilders:
diffMTF = (length - 1) * (WildersAverage(Max(-chgMTF, 0), length) * coeff - WildersAverage(Max(chgMTF, 0), length));
case EMA:
diffMTF = (length - 1) * (ExpAverage(Max(-chgMTF, 0), length) * coeff - ExpAverage(Max(chgMTF, 0), length)) / 2;
}
def valueMTF = priceMTF + if diffMTF >= 0 then diffMTF else diffMTF / coeff;
plot MTFRevEngRSI = if MTF then CompoundValue(1, valueMTF[1], Double.NaN) else Double.NaN;
MTFRevEngRSI.SetDefaultColor(CreateColor(255, 204, 0));
MTFRevEngRSI.SetLineWeight(3);
#top
def coefftop = rsivaluetop / (100 - rsivaluetop);
def difft;
switch (smoothingType) {
case Wilders:
difft = (length - 1) * (WildersAverage(Max(-chg, 0), length) * coefftop - WildersAverage(Max(chg, 0), length));
case EMA:
difft = (length - 1) * (ExpAverage(Max(-chg, 0), length) * coefftop - ExpAverage(Max(chg, 0), length)) / 2;
}
def valuet = price + if difft >= 0 then difft else difft / coefftop;
plot Top = if Current then CompoundValue(1, valuet[1], Double.NaN) else Double.NaN;
Top.SetDefaultColor(Color.RED);
Top.SetLineWeight(1);
# top MTF
def difftMTF;
switch (smoothingType) {
case Wilders:
difftMTF = (length - 1) * (WildersAverage(Max(-chgMTF, 0), length) * coefftop - WildersAverage(Max(chgMTF, 0), length));
case EMA:
difftMTF = (length - 1) * (ExpAverage(Max(-chgMTF, 0), length) * coefftop - ExpAverage(Max(chgMTF, 0), length)) / 2;
}
def valuetMTF = priceMTF + if difftMTF >= 0 then difftMTF else difftMTF / coefftop;
plot MTFTop = if MTF then CompoundValue(1, valuetMTF[1], Double.NaN) else Double.NaN;
MTFTop.SetDefaultColor(Color.RED);
MTFTop.SetLineWeight(1);
#Bottom
def coeffb = rsivalueb / (100 - rsivalueb );
def diffb;
switch (smoothingType) {
case Wilders:
diffb = (length - 1) * (WildersAverage(Max(-chg, 0), length) * coeffb - WildersAverage(Max(chg, 0), length));
case EMA:
diffb = (length - 1) * (ExpAverage(Max(-chg, 0), length) * coeffb - ExpAverage(Max(chg, 0), length)) / 2;
}
def valueb = price + if diffb >= 0 then diffb else diffb / coeffb;
plot Bottom = if Current then CompoundValue(1, valueb[1], Double.NaN) else Double.NaN;
Bottom.SetDefaultColor(Color.GREEN);
Bottom.SetLineWeight(1);
#bottom MTF
def diffbMTF;
switch (smoothingType) {
case Wilders:
diffbMTF = (length - 1) * (WildersAverage(Max(-chgMTF, 0), length) * coeffb - WildersAverage(Max(chgMTF, 0), length));
case EMA:
diffbMTF = (length - 1) * (ExpAverage(Max(-chgMTF, 0), length) * coeffb - ExpAverage(Max(chgMTF, 0), length)) / 2;
}
def valuebMTF = priceMTF + if diffbMTF >= 0 then diffbMTF else diffbMTF / coeffb;
plot MTFBottom = if MTF then CompoundValue(1, valuebMTF[1], Double.NaN) else Double.NaN;
MTFBottom.SetDefaultColor(Color.GREEN);
MTFBottom.SetLineWeight(1);
plot down = if Current then close crosses below Top else Double.NaN;
plot up = if Current then close crosses above Bottom else Double.NaN;
plot downMTF = if MTF then closeMTF crosses below MTFTop else Double.NaN;
plot upMTF = if MTF then closeMTF crosses above MTFBottom else Double.NaN;
down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up.SetDefaultColor(Color.YELLOW);
down.SetDefaultColor(Color.YELLOW);
up.SetLineWeight(1);
down.SetLineWeight(1);
downMTF.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
upMTF.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upMTF.SetDefaultColor(Color.CYAN);
downMTF.SetDefaultColor(Color.MAGENTA);
upMTF.SetLineWeight(1);
downMTF.SetLineWeight(1);
#OB
def coeffOB = rsivalueOB / (100 - rsivalueOB);
def diffOB;
switch (smoothingType) {
case Wilders:
diffOB = (length - 1) * (WildersAverage(Max(-chg, 0), length) * coeffOB - WildersAverage(Max(chg, 0), length));
case EMA:
diffOB = (length - 1) * (ExpAverage(Max(-chg, 0), length) * coeffOB - ExpAverage(Max(chg, 0), length)) / 2;
}
def valueOB = price + if diffOB >= 0 then diffOB else diffOB / coeffOB;
plot RSIOB = if Current and Extreme then (CompoundValue(1, valueOB[1], Double.NaN)) else Double.NaN;
RSIOB.SetDefaultColor(Color.DARK_RED);
RSIOB.SetLineWeight(2);
#OB MTF
def diffOBMTF;
switch (smoothingType) {
case Wilders:
diffOBMTF = (length - 1) * (WildersAverage(Max(-chgMTF, 0), length) * coeffOB - WildersAverage(Max(chgMTF, 0), length));
case EMA:
diffOBMTF = (length - 1) * (ExpAverage(Max(-chgMTF, 0), length) * coeffOB - ExpAverage(Max(chgMTF, 0), length)) / 2;
}
def valueOBMTF = priceMTF + if diffOBMTF >= 0 then diffOBMTF else diffOBMTF / coeffOB;
plot MTFRSIOB = if MTF and Extreme then (CompoundValue(1, valueOB[1], Double.NaN)) else Double.NaN;
MTFRSIOB.SetDefaultColor(Color.DARK_RED);
MTFRSIOB.SetLineWeight(2);
#OS
def coeffOS = rsivalueOS / (100 - rsivalueOS);
def diffOS;
switch (smoothingType) {
case Wilders:
diffOS = (length - 1) * (WildersAverage(Max(-chg, 0), length) * coeffOS - WildersAverage(Max(chg, 0), length));
case EMA:
diffOS = (length - 1) * (ExpAverage(Max(-chg, 0), length) * coeffOS - ExpAverage(Max(chg, 0), length)) / 2;
}
def valueOS = price + if diffOS >= 0 then diffOS else diffOS / coeffOS;
plot RSIOS = if Current and Extreme then (CompoundValue(1, valueOS[1], Double.NaN)) else Double.NaN;
RSIOS.SetDefaultColor(Color.DARK_GREEN);
RSIOS.SetLineWeight(2);
#OS MTF
def diffOSMTF;
switch (smoothingType) {
case Wilders:
diffOSMTF = (length - 1) * (WildersAverage(Max(-chgMTF, 0), length) * coeffOS - WildersAverage(Max(chgMTF, 0), length));
case EMA:
diffOSMTF = (length - 1) * (ExpAverage(Max(-chgMTF, 0), length) * coeffOS - ExpAverage(Max(chgMTF, 0), length)) / 2;
}
def valueOSMTF = priceMTF + if diffOSMTF >= 0 then diffOSMTF else diffOSMTF / coeffOS;
plot MTFRSIOS = if MTF and Extreme then (CompoundValue(1, valueOSMTF[1], Double.NaN)) else Double.NaN;
MTFRSIOS.SetDefaultColor(Color.DARK_GREEN);
MTFRSIOS.SetLineWeight(2);
def OB = price > Top;
def OS = price < Bottom;
def Neutral = price < Top and price > Bottom;
def ARSI = price > RevEngRSI;
def BRSI = price < RevEngRSI;
AssignPriceColor(if ColorBar and OB then Color.MAGENTA else if ColorBar and OS then Color.CYAN else if ColorBar and ARSI then Color.GREEN else if ColorBar and BRSI then Color.RED else Color.CURRENT);
#MTF Colors
def OBMTF = priceMTF > MTFTop;
def OSMTF = priceMTF < MTFBottom;
def NeutralMTF = priceMTF < MTFTop and priceMTF > MTFBottom;
AssignPriceColor(if MTF and MTFColorBar and OBMTF then Color.RED else if MTF and MTFColorBar and OSMTF then Color.GREEN else if MTF and MTFColorBar and NeutralMTF then Color.WHITE else Color.CURRENT);
# Volatility Bands
input BBands = yes;
def STDEV_Multiplier = 2;
input Volatility_Band = 14;
def RSI_Price = 0; #0-6
def RSI_Price_Line = 2;
input RSI_Period = 14;
def averageType = AverageType.EXPONENTIAL;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def DYNRSI = reference RSI(RSI_Period);
def Price1 = if averageType == AverageType.SIMPLE then Average(price, RSI_Price_Line) else ExpAverage(price, RSI_Price_Line);
def SDBB = StDev(price, Volatility_Band);
def DYNAverage = Average(price, Volatility_Band);
#DYNAverage.SetDefaultColor(Color.YELLOW);
#DYNAverage.SetLineWeight(1);
plot UpperBollinger = if Current and BBands then DYNAverage + STDEV_Multiplier * SDBB else Double.NaN;
UpperBollinger.SetDefaultColor(Color.RED);
plot LowerBollinger = if Current and BBands then DYNAverage - STDEV_Multiplier * SDBB else Double.NaN;
LowerBollinger.SetDefaultColor(Color.GREEN);
UpperBollinger.SetLineWeight(2);
LowerBollinger.SetLineWeight(2);
AddCloud(UpperBollinger, Top, Color.RED, Color.DARK_GRAY);
AddCloud(Bottom, LowerBollinger, Color.GREEN, Color.DARK_GRAY);
# MTF Volatility Bands
def NetChgAvgMTF = MovingAverage(averageType, priceMTF - priceMTF[1], length);
def TotChgAvgMTF = MovingAverage(averageType, AbsValue(priceMTF - priceMTF[1]), length);
def ChgRatioMTF = if TotChgAvgMTF != 0 then NetChgAvgMTF / TotChgAvgMTF else 0;
def DYNRSIMTF = reference RSI(RSI_Period);
def Price1MTF = if averageType == AverageType.SIMPLE then Average(priceMTF, RSI_Price_Line) else ExpAverage(priceMTF, RSI_Price_Line);
def SDBBMTF = StDev(priceMTF, Volatility_Band);
def DYNAverageMTF = Average(priceMTF, Volatility_Band);
#DYNAverage.SetDefaultColor(Color.YELLOW);
#DYNAverage.SetLineWeight(1);
plot MTFUpperBollinger = if MTF and BBands then DYNAverageMTF + STDEV_Multiplier * SDBBMTF else Double.NaN;
MTFUpperBollinger.SetDefaultColor(Color.RED);
plot MTFLowerBollinger = if MTF and BBands then DYNAverageMTF - STDEV_Multiplier * SDBBMTF else Double.NaN;
MTFLowerBollinger.SetDefaultColor(Color.GREEN);
AddCloud(MTFUpperBollinger, MTFTop, Color.RED, Color.GRAY);
AddCloud(MTFBottom, MTFLowerBollinger, Color.GREEN, Color.GRAY);
# SQUEEZE
def displace = 0;
def lengths = 14;
def Num_Dev_Dn = -2.0;
def Num_Dev_up = 2.0;
input Squeeze = yes;
def averageTypes = AverageType.SIMPLE;
def sDev = StDev(data = price[-displace], length = lengths);
def MidLine = if Squeeze then MovingAverage(averageTypes, data = price[-displace], length = lengths) else Double.NaN;
def LowerBand = if Squeeze then MidLine + Num_Dev_Dn * sDev else Double.NaN;
def UpperBand = if Squeeze then MidLine + Num_Dev_up * sDev else Double.NaN;
#KELTNER CHANNELS
def factorH = 1.0;
def factorM = 1.5;
def trueRangeAverageType = AverageType.SIMPLE;
def shiftH = factorH * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengths);
def shiftM = factorM * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengths);
def average = MovingAverage(averageTypes, price, lengths);
def Avg = average[-displace];
def Upper_BandH = if Squeeze then average[-displace] + shiftH[-displace] else Double.NaN;
def Lower_BandH = if Squeeze then average[-displace] - shiftH[-displace] else Double.NaN;
def Upper_BandM = if Squeeze then average[-displace] + shiftM[-displace] else Double.NaN;
def Lower_BandM = if Squeeze then average[-displace] - shiftM[-displace] else Double.NaN;
AddCloud(if Squeeze and Upper_BandH < UpperBand and Upper_BandH < Upper_BandM then Double.NaN else Upper_BandH, UpperBand, Color.YELLOW, Color.YELLOW);
AddCloud(if Squeeze and Lower_BandH > LowerBand then Double.NaN else Lower_BandH, LowerBand, Color.YELLOW, Color.YELLOW);
AddCloud(if Squeeze and Upper_BandM < UpperBand then Double.NaN else Upper_BandM, UpperBand, Color.RED, Color.RED);
AddCloud(if Squeeze and Lower_BandM > LowerBand then Double.NaN else Lower_BandM, LowerBand, Color.RED, Color.RED);
# MTF SQUEEZE
input MTFSqueeze = yes;
def sDevMTF = StDev(data = priceMTF[-displace], length = lengths);
def MidLineMTF = if MTFSqueeze then MovingAverage(averageTypes, data = priceMTF[-displace], length = lengths) else Double.NaN;
def LowerBandMTF = if MTFSqueeze then MidLineMTF + Num_Dev_Dn * sDevMTF else Double.NaN;
def UpperBandMTF = if MTFSqueeze then MidLineMTF + Num_Dev_up * sDevMTF else Double.NaN;
#KELTNER CHANNELS
def HIGHMTF = high(period = aggregationPeriod);
def lowMTF = low(period = aggregationPeriod);
def shiftHMTF = factorH * MovingAverage(trueRangeAverageType, TrueRange(HIGHMTF, closeMTF, lowMTF), lengths);
def shiftMMTF = factorM * MovingAverage(trueRangeAverageType, TrueRange(HIGHMTF, closeMTF, lowMTF), lengths);
def averageMTF = MovingAverage(averageTypes, priceMTF, lengths);
def Upper_BandHMTF = if MTFSqueeze then averageMTF[-displace] + shiftHMTF[-displace] else Double.NaN;
def Lower_BandHMTF = if MTFSqueeze then averageMTF[-displace] - shiftHMTF[-displace] else Double.NaN;
def Upper_BandMMTF = if MTFSqueeze then averageMTF[-displace] + shiftMMTF[-displace] else Double.NaN;
def Lower_BandMMTF = if MTFSqueeze then averageMTF[-displace] - shiftMMTF[-displace] else Double.NaN;
AddCloud(if MTFSqueeze and Upper_BandHMTF < UpperBandMTF and Upper_BandHMTF < Upper_BandMMTF then Double.NaN else Upper_BandHMTF, UpperBandMTF, Color.YELLOW, Color.YELLOW);
AddCloud(if MTFSqueeze and Lower_BandHMTF > LowerBandMTF then Double.NaN else Lower_BandHMTF, LowerBandMTF, Color.YELLOW, Color.YELLOW);
AddCloud(if MTFSqueeze and Upper_BandMMTF < UpperBandMTF then Double.NaN else Upper_BandMMTF, UpperBandMTF, Color.RED, Color.RED);
AddCloud(if MTFSqueeze and Lower_BandMMTF > LowerBandMTF then Double.NaN else Lower_BandMMTF, LowerBandMTF, Color.RED, Color.RED);
Last edited: