Thinkorswim Chart Study and Thinkscript Plot Hierarchy


Options Expert
Thinkorswim Chart Study and Thinkscript Plot Hierarchy

Chart study hierarchy within Thinkorswim is one concept that I haven’t found any information on so I had to do some experimenting in order to determine the dirty details… During my research I discovered that hierarchy differs between the chart study panels and thinkscript code itself… I’ll cover the nuances of each here in an effort to shed light on the subject…

Let’s go over the upper chart panel hierarchy first… Have you ever wanted one study to display on top of another rather than vise versa…??? For example, I wanted my Day_Highs_and_Lows indicator lines to be in the background with my chart panel RSI to be in front of most other studies… What I discovered is that the closer to the top of the list a study is, the further in the background that chart layer paints and the closer to the bottom of the study stack a study is, the closer to the foreground that chart layer paints… Either using the up and down arrows in the study controls on the right of the panel or dragging and dropping into the preferred hierarchy achieves this task… The same goes for some but not all studies in the lower chart panel when stacked in a single lower section… The figures below illustrate the difference in stack painting order within chart study panels...

RSI Indicator Under Day_Highs_and_Lows Indicator


RSI Indicator Over Day_Highs_and_Lows Indicator


Now onto plot hierarchy within thinkscript code… The hierarchy is the exact opposite for study and strategy scripts where plots are painted… If the script has more than one plot then hierarchy comes into play… For the example here we’ll cover the Waddah_Attar_Explosion study… In the default code I use the ex and xLine plots were painting behind the histogram which wasn’t the most ideal location for such important components… Within script code the foreground plots need to be at the top of the plot stack and background plots should be at the bottom of the plot stack… By moving the ex and xLine plots to the top of the stack they now paint on top of the histogram… I have my xLine line painting on top of ex to make it easier to see when ex has dipped below xLine which indicates a no trade scenario when settings are correctly calibrated… To accomplish all of this I moved the xLine plot to the top of the stack with xLine directly below ex with the histogram plots at the bottom of the stack… The figures below illustrate the difference in stack painting order within chart study scripts...

ex and xLine Behind Histogram


ex and xLine Over Histogram


Edited to add: The image above show a No-Trade condition where the white ex line has dipped behind and below the blue xLine, even if the a green bar painted above the lines it would still be a No-Trade condition unless multiple other indicators signal otherwise... And without even seeing the chart I can tell that the instrument is in a stretch of chop, probably downtrend...

I hope someone will find this information helpful… I am forever tweaking thinkscript code and like seeing data plotted and painted in a manner that suits my preferences best… Data is only worthwhile if we can interpret it rapidly and accurately...
Last edited:

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

Hi all,
I was hoping I could find out how to have the moving average line in front of the histogram for easier reading. Is it possible to reorder indicator elements?
I appreciate your time, thanks!
# Volatility Gauge

# Measures Volatility using price range and plots a stochastic of price range

# Typical Progression: Volatility to trending to low volatilty. (Price may continue trending after low volatility for quite a few bars before expanding again) High Volatility will typically mark a pivot ara low. 

# Mobius

# V01.10.2018

declare lower;

input n = 8;
input AvgType = AverageType.Exponential;

def h = high;
def l = low;
def c = close;
def max = max(h, c[1]);
def min = min(l, c[1]);
def r = max - min;
def hR = highest(r, n);
def lR = lowest(r, n);
def Vol_r = (r - lR) / (hR - lR);

plot avg = MovingAverage(AvgType, Vol_r, n);
     avg.AssignValueColor(if avg < .382 
                          else if avg > .618 

def hh = highest(h, n);
def ll = lowest(l, n);
plot stoch = MovingAverage(AvgType, (c - ll) / (hh - ll), n);
     stoch.AssignValueColor(if stoch > stoch[1]

addLabel(1, if avg < .382 
            then "Low Volatility"
            else if avg > .618 
                 then "High Volatility Look for Pivot Low"
                 else "Normal / Trending",
# End Code Volatility Gauge

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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