Lane's Stochastic Divergence Indicator for ThinkorSwim

BenTen

Administrative
Staff
VIP
Here is one of the momentum oscillators for ThinkorSwim called Lane Divergence. It shows bullish and bearish signals on the lower study of your chart. The overbought area is set to 80 while the oversold area is set to 20, similar to RSI parameters.

The indicator also comes with an alert system.



thinkScript Code

Rich (BB code):
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);

Shareable Link

https://tos.mx/Wcmk2L
 
Last edited:

jr2146

New member
Hi All,

I was wondering if anyone can please help me to create a code.

Here is what I am looking for:

I use a 1 minute chart to trade the /ES futures and the Fast Stochastic only showing the D% 3, and I look for divergence from price and the fast stoch. I look for price to make a low and the fast stoch to make a low and than a bounce and then price makes a lower low but the fast stoch makes a higher low... What I am looking for is a code that alerts me when this happens so I visually can see it... Its very similar to some of the Macd divergence codes out there of divergence... I just would like one for the fast stochastics... I also have what I call a "waterfall code" that paints the bar and sends an sound alert when we are making new lows on price and the current candle price breaks above the previous candles high by 1 tick. Below is my chart with the waterfall code so you can see it and pretty much just need a code now to draw lines of the divergence with conformation using the watrefall code... I hope that makes sense... Any help would be great... Thank you all..

Also below I will paste my trade rules of this trade setup for anyone who wants to learn to trade this trade setup....

Here is a chart with the waterfall code and the fast stoch. https://tos.mx/5LvnSw


Thank you again all.

-------------------------------------------------------------------------------------------------------
Trading Plan For 1 Minute Lower Low Divergence Using Micro /MES Contract:


*** Use the Fast Stoch using the D% 3 and hide the K% 9 on chart using TOS
*** Just flip everything over for a higher high stoch Divergence (Rising Price’s)

1. Look for a low in price with an oversold low stoch
2. Watch for a bounce in price and the stoch (They should bounce together)
3. Than look for a new low in price and a higher low on the Stoch
4. Watch for the Waterfall Trade Setup
5. Also look for a Support / Resistance level to lean against and a Reversal Candle for the trigger candle (Hammer, Shooting Star, Engulfment Candle...ect)
6. Place a buy bid order when price breaks the waterfall (1 tick above the high of the previous candle) and look for 1 - 2 point target
7. Your stop goes 1 tick below the lowest candles low of waterfall (in theory, price should not break below the lower low of price and the higher low of the stoch)
8. If target is not hit and price pulls back add a 2nd order to add to position half back (50% trade setup) for a possible pull back trade setup
9. The stop of 2nd order goes 1 tick below lowest low candle (same stop as first trade)
10. The target is 1 - 2 points on the pull back entry
11. Always be patient for the trade setup and don’t force the trade, if you miss the trade wait for the next trade setup


Trading Plan For 1 Minute Lower Low Divergence Using The Big \ES Contract:

*** Use the Fast Stoch using the D% 3 and hide the K% 9 on chart using TOS
*** Just flip everything over for a higher high stoch Divergence (Rising Price’s)

1. Look for a low in price with an oversold low stoch
2. Watch for a bounce in price and the stoch (They should bounce together)
3. Than look for a new low in price and a higher low on the Stoch
4. Watch for the waterfall trade setup
5. When price breaks the waterfall wait for a pullback and put an order 2-3 ticks above the waterfall’s lowest candle and your target should be 2-3 ticks profit
6. The stop should go 1 tick below the waterfall’s lowest low candle (in theory, price should not break below the lower low of price and the higher low of the stoch)
7. Your total risk should only be 2-3 ticks
8. You can always do multiple contracts and scale out with only 2-3 ticks per contract of risk
9. Always be patient for trade setup and don’t force the trade, if you miss the trade wait for the next trade setup
 

scotty

New member
Does anyone have a link the George C. Lanes paper on stochastics? I know how this is supposed to be used is NOT the most common interpretation and I've used with luck but would like to perfect it. As I understand only divergences are to be traded or is that not the case with this modded indicator? Thanks


***edit i have found one, it is available for $4 online athttps://store.traders.com/ (it's a 90s website but the pdf is valid)
 
Last edited:

zeek

Active member
2019 Donor
Really nice indicator!

Wondering if someone can help me modify the script to only show the arrow signals if price is in overbought/oversold area?
And would also like to only show the red & green divergence arrows and not the white ones.
 

Evo_div

New member
Hey @BenTen - Just found this indicator and it's something very close to what I've been looking quite a while for!

Would it be difficult to also make this same indicator based on the Fast Stochastic?
 

scotty

New member
Hey @BenTen - Just found this indicator and it's something very close to what I've been looking quite a while for!

Would it be difficult to also make this same indicator based on the Fast Stochastic?
Changing the K value from 14 to say 5 would do this no? Fast stochastics run at a 5,3 whereas TOS default slow is 10,10 I believe. I know there might be some other differences but I've played around with this some as well.
 

JakeD

New member
@BenTen The white arrow signals a stochs crossover but no divergence?

The Red Arrows are "normal bearish divergence"
The Green Arrows are "normal bullish divergence"
The White Arrows on top (pointing down) are "hidden bearish divergence"
The White Arrows on bottom (pointing up) are "hidden bullish divergence"

normal bearish divergence = higher high on stock correlating w lower high on indicator
normal bullish divergence = lower low on stock correlating w higher low on indicator
hidden bearish divergence = lower high on stock corelating with higher high on indicator
hidden bullish divergence = higher low on stock correlating with lower low on indicator

Normal Divergence is Trend Reversal Signal
Hidden Divergence is a Trend Continuation Signal

Hope this is helpful.
 
  • Like
Reactions: DDW

Similar threads

Top