Defining the index a symbol is apart of


2019 Donor
Is possible in thinkScript to define what index a symbol is in?
For example:
def market = getMarket(<symbol>)

I feel like this should be an easy thing for tos to reference but I can't find an example of it being used...


Not sure if this snippet can be of any help.

# Market Breath Ratios
# Paris (based on an earlier idea from ESP)
# 11.02.2015

def UVOL   = close(“$UVOL”);
def DVOL   = close(“$DVOL”);

def UVOLD  = close(“$UVOLI”);
def DVOLD  = close(“$DVOLI”);

def UVOLS  = close(“$UVOLSP”);
def DVOLS  = close(“$DVOLSP”);

def UVOLN  = close(“$UVOL/Q”);
def DVOLN  = close(“$DVOL/Q”);

def UVOLR  = close(“$UVOLRL”);
def DVOLR  = close(“$DVOLRL”);


2019 Donor
I'm not sure if that would work for this case. Say I wanted to define the index of the symbol as the user switches between them like AAPL as NDX or F as SPX without asking the end-user to select the market from a dropdown and with-out an if statement long enough to take us to the moon and back.


2019 Donor
After thinking about it a little more, I guess it wouldn't make sense because stocks can be listed on multiple indexes, so just going with SPX is most likely the best option most of the time. Unless your looking at small and micro caps which switching to the Russell would be more beneficial for pulling in the 200 day MA of the overarching index.

Similar threads