Volatility Sentiment For ThinkOrSwim

FutureTony

Well-known member
VIP
I was inspired to start this one by @Chemmy over in the Top 5 Ticker thread. It plots the price movement of a different ticker in the lower as a comparison tool. I have added a 9 and 21 period cloud to show the current 'trend' of the ticker. The idea here is to use a volatility product (eg. UVXY, /VX, VIX) and identify trend and divergence as shown here:
6U5IHk5.png

I've included a multi-timeframe setting so you can change the lower to any timeframe LARGER than what you are currently viewing. The default is 5 minutes as I like comparing this with a 2 minute chart on ES. As you can see from the image, I like to include Emojis in my labels as they take up less space that way. You will need to add your own as study options as adding them directly in the code will not work properly. I like 🐂 and 🐻.
One other thing to note - this uses the undocumented AddChart feature in thinkscript. You may have to check 'Fit Studies' to make sure you see the complete range for the lower indicator.

And as I was backtesting this, one thing that occurred to me is this would also be an interesting way to track ICT's 'smart money technique' when one index makes a new high (or low) and the other does not. To use this study for that, change the ticker to /NQ or /YM if you are comparing to ES. Check it out and let me know what you think!

Ruby:
declare lower;

# created by @tony_futures to identify trend and divergence between the futures and a volatility product
input TICKER = "-/VX";
def NaN = Double.NaN;
input Aggr = AggregationPeriod.FIVE_MIN;
input higherAgg = yes;
def Agg = if higherAgg then Aggr else getAggregationPeriod();
def tickerHigh = high(symbol=TICKER, period = Agg);
def tickerLow = low(symbol=TICKER, period = Agg);
def tickerClose = close(symbol=TICKER, period = Agg);
def tickerOpen = open(symbol=TICKER, period = Agg);
def isUp = tickerClose > tickerOpen;
def isDown = tickerClose < tickerOpen;
def isDoji = tickerClose == tickerOpen;
DefineGlobalColor("greenCandle", CreateColor(103, 135, 151));
DefineGlobalColor("redCandle", CreateColor(136, 93, 100));
DefineGlobalColor("dojiCandle", Color.WHITE);

input fastLength = 9;
input slowLength = 21;
input bearish = "";
input bullish = "";

def EMA1 = MovAvgExponential(tickerClose, (fastLength), 0 , no);
def EMA2 = MovAvgExponential(tickerClose, (slowLength), 0 , no);
AddCloud(EMA1,EMA2,GlobalColor("greenCandle"),GlobalColor("redCandle"));

def BullEMA = EMA1 > EMA2;
def xC = close(period = Agg);
def EMACurrent1 = MovAvgExponential(xC, (fastLength), 0 , no);
def EMACurrent2 = MovAvgExponential(xC, (slowLength), 0 , no);

def BullCurrentEMA = EMACurrent1 > EMACurrent2;

def divergentBullEMA = BullEMA and !BullCurrentEMA;
def divergentBearEMA = !BullEMA and BullCurrentEMA;

input showDivergenceLabel = yes;
input currentTicker = "ES";
AddLabel(showDivergenceLabel and divergentBullEMA,"Possible Bullish Divergence",GlobalColor("greenCandle"));
AddLabel(showDivergenceLabel and divergentBearEMA,"Possible Bearish Divergence",GlobalColor("redCandle"));

AddLabel(!BullEMA,"Vol" + bearish, GlobalColor("redCandle"));
AddLabel(BullEMA,"Vol" + bullish, GlobalColor("greenCandle"));
AddLabel(!BullCurrentEMA,currentTicker + bearish, GlobalColor("redCandle"));
AddLabel(BullCurrentEMA,currentTicker + bullish, GlobalColor("greenCandle"));

AddChart(if (isUp) then tickerLow else NaN, if (isUp) then tickerHigh else Double.NaN,  NaN,  NaN, ChartType.BAR, GlobalColor("greenCandle"));
AddChart(if (isDown) then tickerLow else NaN, if (isDown) then tickerHigh else Double.NaN,  NaN, NaN, ChartType.BAR,  GlobalColor("redCandle"));
AddChart(if (isDoji) then tickerLow else NaN, if (isDoji) then tickerHigh else Double.NaN, if (isDoji) then tickerOpen else NaN, if (isDoji) then tickerClose else NaN, ChartType.BAR,  GlobalColor("dojiCandle"));
 
Last edited:
I'm a bit confused on this, I have it showing VIX on the lower indicator and I get that, but in the settings, it has "current ticker". Is that current ticker what it's comparing against to get the cloud? I'm a bit confused. Like I can have AAPL on my main chart, the lower indicator is showing VIX, but the current ticker is /es. So are the clouds showing a divergence from VIX and /ES on the lower indicator, and I assume it has nothing to do with AAPL I have loaded in my main chart?

Apologies for lack of a picture, it was giving me issues getting it uploaded here.
 
I'm a bit confused on this, I have it showing VIX on the lower indicator and I get that, but in the settings, it has "current ticker". Is that current ticker what it's comparing against to get the cloud? I'm a bit confused. Like I can have AAPL on my main chart, the lower indicator is showing VIX, but the current ticker is /es. So are the clouds showing a divergence from VIX and /ES on the lower indicator, and I assume it has nothing to do with AAPL I have loaded in my main chart?

Apologies for lack of a picture, it was giving me issues getting it uploaded here.
Hmm, I probably could have been clearer in my description. If you are looking at an AAPL chart, it is showing you VIX and then the LABEL is for the 9/21 average on VIX and AAPL. The currentTicker option is just the text that shows up on the label. Hopefully that makes more sense.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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