declare lower;
################################
# Original script by Cwparker23 #
################################
#-----------------
#- DISCLAIMER
#-----------------
#- I am not a certified financial advisor. The content of this page/site and tools are for informational purposes only and does not constitute financial or legal advice. Under no circumstances will the author be responsible for errors or use of this tool and site. User assumes all risks.
# =========================
# Inputs
# =========================
input rsiLength = 14;
input price = close;
# Sigma levels (from video)
input zOB_Top = 2.14;
input zOB_Bot = 1.73;
input zRes_Top = 1.00;
input zRes_Bot = 0.66;
input zSup_Top = -0.66;
input zSup_Bot = -1.00;
input zOS_Top = -1.73;
input zOS_Bot = -2.14;
# =========================
# RSI
# =========================
def r = RSI(price = price, length = rsiLength);
plot RSIline = r;
RSIline.SetLineWeight(2);
RSIline.SetDefaultColor(Color.WHITE);
# =========================
# Helper: sigma -> RSI via tanh (manual)
# =========================
script SigmaToRSI {
input z = 0.0;
input len = 14;
def x = z / Sqrt(len - 1);
def e2x = Exp(2 * x);
def tanh = (e2x - 1) / (e2x + 1);
plot out = 50 + 50 * tanh;
}
# =========================
# Zones
# =========================
plot OB_Top = SigmaToRSI(zOB_Top, rsiLength);
plot OB_Bot = SigmaToRSI(zOB_Bot, rsiLength);
plot Res_Top = SigmaToRSI(zRes_Top, rsiLength);
plot Res_Bot = SigmaToRSI(zRes_Bot, rsiLength);
plot Sup_Top = SigmaToRSI(zSup_Top, rsiLength);
plot Sup_Bot = SigmaToRSI(zSup_Bot, rsiLength);
plot OS_Top = SigmaToRSI(zOS_Top, rsiLength);
plot OS_Bot = SigmaToRSI(zOS_Bot, rsiLength);
plot MidLine = 50;
# =========================
# Styling
# =========================
OB_Top.SetDefaultColor(Color.DARK_GREEN);
OB_Bot.SetDefaultColor(Color.DARK_GREEN);
OS_Top.SetDefaultColor(Color.DARK_RED);
OS_Bot.SetDefaultColor(Color.DARK_RED);
Res_Top.SetDefaultColor(Color.GRAY);
Res_Bot.SetDefaultColor(Color.GRAY);
Sup_Top.SetDefaultColor(Color.GRAY);
Sup_Bot.SetDefaultColor(Color.GRAY);
MidLine.SetDefaultColor(Color.YELLOW);
MidLine.SetLineWeight(2);
# =========================
# Clouds
# =========================
AddCloud(OB_Top, OB_Bot, Color.GREEN, Color.GREEN);
AddCloud(OS_Top, OS_Bot, Color.RED, Color.RED);
AddCloud(Res_Top, Res_Bot, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
AddCloud(Sup_Top, Sup_Bot, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
AddLabel(yes,
"Logit RSI Adaptive Zones | RSI(" + round(RSIline,2) + ")",
Color.GRAY
);
def h = reference RSI(price = high, length = rsiLength) ;
def l = reference RSI(price = low, length = rsiLength);
def o = reference RSI(price = open, length = rsiLength) ;
def c = reference RSI(price = close, length = rsiLength) ;
def isBull = close > open;
def isBear = close <= open;
# Bear candles
AddChart(
high = if isBear then h else Double.NaN,
low = if isBear then l else Double.NaN,
open = if isBear then o else Double.NaN,
close = if isBear then c else Double.NaN,
type = ChartType.CANDLE,
growColor = Color.RED,
fallColor = Color.GREEN,
neutralColor = Color.CURRENT
);
# Bull candles
AddChart(
high = if isBull then h else Double.NaN,
low = if isBull then l else Double.NaN,
open = if isBull then c else Double.NaN,
close = if isBull then o else Double.NaN,
type = ChartType.CANDLE,
growColor = Color.GREEN,
fallColor = Color.RED,
neutralColor = Color.CURRENT
);