Yea I did some onDemand testing and it looks like the arrows do repaint even after the candle closes. Bummer.@fungus12 I have not used this study personally but a review of the code would suggest that the recursive statement for lowest low will continually repaint and then vice-versa with the high.
Hi Ben, I am very new to ToS and trading. I was looking for your indicator. If i understood, this gives a signal of Short when red arrow arrives and Call on White arrow. Could you please let me know if this is how it works? is there any other things i shall notice while looking at it... Any suggestion on what time frame it works best?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
I am not sure what your question is? How what works? How do oscillators work?Hi Ben, I am very new to ToS and trading. I was looking for your indicator. If i understood, this gives a signal of Short when red arrow arrives and Call on White arrow. Could you please let me know if this is how it works? is there any other things i shall notice while looking at it... Any suggestion on what time frame it works best?
Thanks in advance.
@Ronin13 In this version the arrow colors are now global colors. The colors can be modified under settings. HTH
Ruby:# Lane's Stochastic Divergence Indicator for ThinkorSwim # BenTen 3/19/19 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); DefineGlobalColor("ArrowUp", CreateColor(0, 200, 255)) ; DefineGlobalColor("ArrowDn", CreateColor(225, 0, 0)) ; DefineGlobalColor("neutral", color.gray) ; plot posDiv = If(isLow and (positiveDivergenceReg or positiveDivergenceHid), SMIData, Double.NaN); posDiv.AssignValueColor(if positiveDivergenceReg then GlobalColor("ArrowUp") else GlobalColor("neutral")); 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 GlobalColor("ArrowDn") else GlobalColor("neutral")); 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);
Share Link: http://tos.mx/NRHDTWE
It does appear so. But no. Just a coincidence.In post #20 of this thread there is a chart where it looks like the Stochastics study is coloring the price bars to match the stochastics colors, but the study with share link, NRHDTWE, on this page, does not color the price bars. What am I missing? - Thanks.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Elastic Stochastic for ThinkorSwim -Upper and Lower indicator | Indicators | 8 | ||
Stochastic Scalper for ThinkorSwim | Indicators | 12 | ||
Repaints Mobius Full Stochastic MTF for ThinkorSwim | Indicators | 4 | ||
M | Premier Stochastic Oscillator | Indicators | 91 | |
MoneyWave Stochastic Indicator for ThinkorSwim | Indicators | 8 |
Start a new thread and receive assistance from our community.
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.
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.