Cwparker23
Member
RSI with a twist. I added volume to the indicator. The rsi will switch colors according to volume and trend. Gamma Squeeze. then magenta cloud works like a squeeze any time gamma moves above 50. Bullish and bearish divergence.
Code:
################################
# Script by Cwparker23#
################################
declare lower;
input Period = 13;
input price = hlc3;
def l = low;
def h = high;
input averageType = AverageType.SIMPLE ;
def NetChgAvg = MovingAverage(averageType, price - price[1], Period);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), Period);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
DEF VAVG = EXPAVerage (VOlume);
RSI.DefineColor("Normal", GetColor(7));
def haclose = (open + high + low + close) / 4;
def haopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2);
def diff = haclose - haopen;
RSI.AssignValueColor(if diff > 0 and volume > vavG then color.green else if diff > 0 and volume < vavG then color.DARK_green else if diff < 0 and volume > vavG then color.red else if diff < 0 and volume < vavG then color.pink else RSI.color("Normal"));
input showBreakoutSignals = yes;
def isbulldiv = if (rsi > rsi[1] ) > 0 and (L < L[1]) > 0 then 1 else 0;
def isbeardiv = if (rsi < rsi[1] ) > 0 and (H > H[1]) > 0 then 1 else 0;
def PositveDivergence = if
isbulldiv > 0 then
RSI else Double.NaN;
plot PD = if PositveDivergence is true then RSI else Double.NaN;
PD.SetHiding(!showBreakoutSignals);
PD.SetPaintingStrategy(PaintingStrategy.tRIANGLES);
PD.SetDefaultColor(Color.WHITE);
PD.HideBubble();
PD.HideTitle();
def NegativeDivergence = if
isbeardiv > 0 then
RSI else Double.NaN;
plot ND = if NegativeDivergence is true then RSI else Double.NaN;
ND.SetHiding(!showBreakoutSignals);
ND.SetPaintingStrategy(PaintingStrategy.tRIANGLES);
ND.SetDefaultColor(Color.mAGENTA );
ND.HideBubble();
ND.HideTitle();
def sumTR = Sum (TrueRange(high, close, low), Period);
def HMax = Highest (high, Period);
def LMax = Lowest (low, Period);
plot FE = 100 * Log (sumTR / (HMax - LMax)) / Log(Period);
FE.SetDefaultColor(Color.ORANGE);
FE.SetStyle (Curve.FIRM);
FE.SetLineWeight(2);
plot FIFTY = 50;
FIFTY.SetDefaultColor(Color.yellow);
FE.DefineColor("Over50", Color.MAGENTA );
FE.DefineColor("Normal", GetColor(7));
FE.DefineColor("BELOW50", GetColor(1));
FE.AssignValueColor(if FE > 50 then FE.Color("Over50") else if FE < 50 then FE.Color("BELOW50") else FE.Color("Normal"));
DefineGlobalColor("OverBought", Color.PINK);
DefineGlobalColor("OverSold", Color.YELLOW);
AddCloud (100, 78.6, globalColor("OverBought"), globalColor("OverBought"));
AddCloud(23.6, 0, globalColor("OverSold"), globalColor("OverSold"));
AddCloud(61.8, 38.2, Color.gray, Color.gray);
PLOT SQUEEZE_dn = if
(FE > 50) then
RSI else DOuble.NaN;
SQUEEZE_dn.SetPaintingStrategy(PaintingStrategy.POINTS );
AddCloud(70, SQUEEZE_dn, Color.mAGENTA );
AddCloud(SQUEEZE_dn, 30, Color.mAGENTA );
SQUEEZE_dn.SetDefaultColor(Color.yellow);