Original RSI with Gamma added with divergence for ThinkOrSwim

Cwparker23

Member
VIP
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);
il_794xN.3735434944_18e1.jpg
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
333 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top