ADD Chart as a LOWER Study In ThinkOrSwim

markos

Well-known member
VIP
Here are 2 similar but different scripts: Be forwarned, DO NOT Change the Chart Type from CANDLE! I had to re-load ThinkorSwim.

Code:
# Add chart as lower study. Strongly suggest your TOS is backed up & suggest DO NOT change CHART TYPE
# This is "deprecated", unsupported in ThinkScript, there is no documentation.
# Usage example: You may have oil company, CVX, ploted in the upper. And you want to see its price vs oil futures.
# The code below allows you to show the oil futures (/CL) below for comparison.
# There has been talk of potential to put simple study eg MAs in here as well. I don't know anyone that has done it.
# Found in JQs OneNote 2018
# Hacked together by Markos 6-27-19. Parts taken from a few studies.  PLEASE READ NOTES#

declare lower;
input symbol = "SPX"; #Hint add any of these "SPX", "COMP", "DJX", "SOX", "NDX", "OEX", "QQQ", "IWM", "TNX", "/ES", "/CL" ect.
input cType  = ChartType.CANDLE; #Hint: Change chart type at our own risk!
DefineGlobalColor( "uptick", Color.UPTICK );
DefineGlobalColor( "downtick", Color.DOWNTICK );
DefineGlobalColor( "neutral", Color.PLUM );

AddChart( high  = high( symbol ),
          low = low( symbol ),
          open = open( symbol ),
          close = close( symbol ),
          type  = cType,
          growColor = GlobalColor( "uptick" ),
          fallColor = GlobalColor( "downtick" ),
          neutralColor  = GlobalColor( "neutral" )
        );

AddLabel(1, if Security == Security."SPX" then "SPX = S&P 500 INDEX is showing"
else if Security == Security."COMP" then " COMP = NASDAQ COMPOSITE is showing "
else if Security == Security."DJX" then " DJX = DOW JONES INDUSTRIAL AVERAGE INDEX is showing"
else if Security == Security."SOX" then "SOX = PHLX SEMI CONDUCTOR INDEX is showing"
else if Security == Security."NDX" then " NDX = NASDAQ 100 INDEX INDEX is showing"
else if Security == Security."OEX" then "OEX = S & P 100 INDEX is showing"
else if Security == Security."IWM" then " IWM = Russel 2000 Index is showing "
else if Security == Security."QQQ" then "QQQ = POWERSHARES QQQ is showing"
else if Security == Security."TNX" then " TNX = 10-YR TREASURY INDEX is showing"
else if Security == Security."/CL" then "/CL = Light Sweet Crude Oil Futures is showing"
else if Security == Security."/ES" then "/ES = E-mini S&P 500 Index Futures is showing"
else "ERROR – none were found", Color.WHITE);
# EOC #
--------------------------------------------------------------------

##2nd way of putting a chart in Lower pane ##
#ADD AN INDEX OR FUTURE LOWER CHART
#from StanL Archives, White Candles Used
#The AddChart function is unsupported in TOS, Hence there is no documentation to support its use and color formatting.
#Also, not all chart types are supported.
#Usage example: You may have a stock plotted on the upper panel:Say an oil company, CVX. You may want to see how its price varies with the oil futures.

#The code below allows you to show the oil futures (/CL) below for comparison. declare lower;

input chartType = ChartType.CANDLE; #Hint: Do Not Change without Backing up your Desktop!
input Security = {default "SPX", "COMP", "DJX", "SOX", "NDX", "OEX", "QQQ", "IWM", "VIX", "TNX", "/ES", "/CL"};

AddChart( high = high( Security ), low = low( Security ),
open = open( Security ), close = close( Security ), type = chartType );
AddLabel(1, if Security == Security."SPX" then "SPX = S&P 500 INDEX is showing"
else if Security == Security."COMP" then " COMP = NASDAQ COMPOSITE is showing "
else if Security == Security."DJX" then " DJX = DOW JONES INDUSTRIAL AVERAGE INDEX is showing"
else if Security == Security."SOX" then "SOX = PHLX SEMI CONDUCTOR INDEX is showing"
else if Security == Security."NDX" then " NDX = NASDAQ 100 INDEX INDEX is showing"
else if Security == Security."OEX" then "OEX = S & P 100 INDEX is showing"
else if Security == Security."IWM" then " IWM = Russel 2000 Index is showing "
else if Security == Security."QQQ" then "QQQ = POWERSHARES QQQ is showing"
else if Security == Security."VIX" then "VIX = CBOE MARKET VOLATILITY INDEX is showing"
else if Security == Security."TNX" then " TNX = 10-YR TREASURY INDEX is showing"
else if Security == Security."/CL" then "/CL = Light Sweet Crude Oil Futures is showing"
else if Security == Security."/ES" then "/ES = E-mini S&P 500 Index Futures is showing"
else "ERROR – none were found", Color.WHITE);
#end
 

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

Here is the shared link: http://tos.mx/aafJbDx

Code:
# LowerChart
# # [URL]http://finance.groups.yahoo.com/group/TOS_thinkscript/message/15470[/URL]

declare lower;
input Security =  {default "SPX", "COMP", "DJX", "HUI", "MNX", "SOX", "NDX", "OEX", "QQQQ",  "RUT", "VIX", "VXO", "XAU", "QQV", "TNX"};
input Chart = ChartType.BAR;
input PriceType = "Last";
input Periodicity = AggregationPeriod.FIVE_MIN;
input Factor = 1;

def h = high(symbol = Security, period = Periodicity, PriceType = PriceType) / Factor;
def l = low(symbol = Security, period = Periodicity, PriceType = PriceType) / Factor;
def o = open(symbol = Security, period = Periodicity, PriceType = PriceType) / Factor;
def c = close(symbol = Security, period = Periodicity, PriceType = PriceType) / Factor;

AddChart(GrowColor = Color.DARK_GREEN, FallColor = Color.DARK_RED, NeutralColor = Color.GRAY, High = h, Low = l, Open = o, Close = c, Type = Chart);
 
Both of these codes are genius. I like to trade with the tick indexes on the RTY and YM ($TIKRL, $TICK) and this helps so much to see the details in the lower study in unison with price in the upper study. It's a lot cleaner and uncluttered. Thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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