Woodies CCI Divergence Indicator for ThinkorSwim

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

Woodies CCI Divergence
Caveat: Research has found there aren't any scripts that can accurately find divergences, consistently. Eyeballing it is still the best method.

Ruby:
# Woodies CCI Divergence
#  https://usethinkscript.com/threads/woodies-cci-divergence-indicator-for-thinkorswim.12391/
input bar = 2;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

plot Diff =  reference WoodiesCCI("short length" = 6, "long length" = 14, "lower side winder limit" = 30.0, "upper side winder limit" = 100.0)."CCI";

def SwingHigh = Diff > 0 and Diff >= highest(Diff[1], bar) and Diff >= highest(Diff[-bar], bar);
def SHprice = if SwingHigh then Diff else SHprice[1];
def SHBar = if SwingHigh then BarNumber() else SHBar[1];
def CrossBarL = if Diff crosses below 0 then BarNumber() else CrossBarL[1];
def SwingLow = Diff < 0 and Diff <= lowest(Diff[1], bar) and Diff <= lowest(Diff[-bar], bar);
def SLprice = if SwingLow then Diff else SLprice[1];
def SLBar = if SwingLow then BarNumber() else SLBar[1];
def CrossBarH = if Diff crosses above 0 then BarNumber() else CrossBarH[1];
def SHSP = if SwingHigh then high else SHSP[1];
def SLSP = if SwingLow then low else SLSP[1];
def BearDiv = Diff > 0 and CrossBarL[1] > SHBar[1] and Diff < SHprice[1] and high > SHSP[1] and SHprice[1] - Diff > 0.005;
def BullDiv = Diff < 0 and CrossBarH[1] > SLBar[1] and Diff > SLprice[1] and low < SLSP[1] and Diff - SLprice[1] > 0.005;
def HiddenBearDiv = Diff > 0 and Diff > SHprice[1] and high < SHSP[1] and Diff - SHprice[1] > 0.005;
def HiddenBullDiv = Diff < 0 and Diff < SLprice[1] and low > SLSP[1] and SLprice[1] - Diff > 0.005;

plot BearD = if BearDiv then high else Double.NaN;
        BearD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
        BearD.AssignValueColor(Color.RED);
        BearD.SetLineWeight(3);

plot BullD = if BullDiv then low else Double.NaN;
        BullD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
        BullD.AssignValueColor(Color.UPTICK);
        BullD.SetLineWeight(3);

plot HiddenBearD = if HiddenBearDiv then high else Double.NaN;
        HiddenBearD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
        HiddenBearD.AssignValueColor(Color.PINK);
        HiddenBearD.SetLineWeight(1);

plot HiddenBullD = if HiddenBullDiv then low else Double.NaN;
        HiddenBullD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
        HiddenBullD.AssignValueColor(Color.LIME);
        HiddenBullD.SetLineWeight(1);

Alert(BearDiv[1], "Short MACD divergence", Alert.BAR, Sound.Ring);
Alert(BullDiv[1], "Long MACD divergence", Alert.BAR, Sound.Ring);
Alert(HiddenBearDiv[1], "Short hidden MACD divergence", Alert.BAR, Sound.Ring);
Alert(HiddenBullDiv[1], "Long hidden MACD divergence", Alert.BAR, Sound.Ring);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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