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
 

Picard

Member
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);
 

bobomatic

New member
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

Top