Stochastic RSI with Divergence

MJFLOHIGH

New member
Plus
I've been trading using divergence for a while on tradingview but the studies and alerts via TOS scans are much more effective for me. But I'm not a coder. Is there anyone who can help with the creation of or location of a Stochastic RSI with divergence for TOS? I have the Lane Stochastic with Divergence that is working but traditional Lane Stochastics only look at the Price variable. I like the sensitivity of the combination of the RSI and Price Stochastics analysis. I'm new here so please let me know if I need to post this somewhere else. Thanks in advance and for the great dialogue here!

I found the Lane Stochastic Divergence from @TenPen. The divergence calulation for the stocastic is awesome and works well. I'm just reallying wanting to see if there is a way to take the calcuations here and covert them for use with a Stochastic RSI with Divergences. I understand that It's a little more complex because of the inclusion of the RSI Calulation and length. The link to the Lane Stochastic RSI is below. Please let me know your thoughts. Open to disucss.

New to UseThinkScript. Is there anyway that you can easily convert the calculations you use in the Lanes Stochastic Divergence (seen below)
https://usethinkscript.com/threads/lanes-stochastic-divergence-indicator-for-thinkorswim.80/
to a divergence indicator for the Stochastic RSI?

In another chat/post I asked for the conversion of a tradingview script that I use,
https://usethinkscript.com/threads/convert-tradingview-stochastic-rsi-with-divergences.20146/
but I like how you have coded the previous HH and LH etc. here for the stochastic. I just like using the StochRSI based on my trading style. Unfortunately, I'm not good at coding. Please advise and thankks in advance. .
Rich (BB code):
#Lane Divergence
declare lower;

input over_bought = 80.0;
input over_sold = 20.0;
input percentDLength = 3;
input percentKLength = 14;
input AudibleAlert = yes;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;
def avgrel = Average(Average(rel_diff, percentDLength), percentDLength);
def avgdiff = Average(Average(diff, percentDLength), percentDLength);
def SMIData = (avgrel / (avgdiff / 2) + 1) * 50;

def isLow = If (SMIData < SMIData[-1] and SMIData < SMIData[1], 1, 0);
def isHigh =   If (SMIData > SMIData[-1] and SMIData > SMIData[1], 1, 0);

rec prevLowSMI = CompoundValue(1, If(isLow[1], SMIData[1], prevLowSMI[1]),

0);
rec prevHighSMI = CompoundValue(1, If(isHigh[1], SMIData[1], prevHighSMI

[1]), 0);

rec prevLow =  CompoundValue(1, If(isLow[1], low, prevLow[1]), low);
rec prevHigh =  CompoundValue(1, If(isHigh[1], high, prevHigh[1]), high);

def positiveDivergenceReg = If (SMIData > prevLowSMI and low < prevLow, 1,

0);
def positiveDivergenceHid = If (SMIData < prevLowSMI and low > prevLow, 1,

0);

plot posDiv = If(isLow and (positiveDivergenceReg or

positiveDivergenceHid), SMIData, Double.NaN);
posDiv.AssignValueColor(if positiveDivergenceReg then Color.GREEN else

Color.white);
posDiv.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
posDiv.SetLineWeight(2);

def negativeDivergenceReg =  If (SMIData < prevHighSMI and high > prevHigh,

1, 0);
def negativeDivergenceHid = If (SMIData > prevHighSMI and high < prevHigh,

1, 0);

plot negDiv = If(isHigh and ( negativeDivergenceReg or

negativeDivergenceHid), SMIData, Double.NaN);
negDiv.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
negDiv.AssignValueColor(if negativeDivergenceReg then Color.RED else

Color.white);
negDiv.SetLineWeight(2);

plot AvgSMI = Average(SMIData, percentDLength);
AvgSMI.SetDefaultColor(Color.GRAY);

plot overbought = over_bought;
overbought.SetDefaultColor(Color.WHITE);
overbought.SetStyle(Curve.SHORT_DASH);

plot oversold = over_sold;
oversold.SetDefaultColor(Color.WHITE);
oversold.SetStyle(Curve.SHORT_DASH);

plot SMI = SMIData;
SMI.AssignValueColor(if SMI > SMI[1] then Color.GREEN else Color.RED);
SMI.SetLineWeight(2);

# Sound alerts
Alert(AudibleAlert and positiveDivergenceReg, "Time TO Buy", Alert.BAR,
Sound.Ring);
Alert(AudibleAlert and negativeDivergenceReg, "Time TO Sell", Alert.BAR,
Sound.Ring);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
406 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