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. .
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: