• Get $40 off VIP by signing up for a free account! Sign Up

creating label for $ADD

crscrs85

Member
Im trying to get a label for a few different indicators onto my chart. can someone tell me why lines 9 and 10 are invalid



declare lower;

input symbol = "$ADD";

def SPYprice = close(symbol = "SPY");

def $ADDprice = close(symbol="$ADD");
def $ADDvalue = close(symbol="$ADD");

#def symbol = close(symbol="$ADD");
#plot symbol = close(symbol="$ADD");
 
Remove " $ ":

def ADDprice = close(symbol="$ADD");
def ADDvalue = close(symbol="$ADD");
Thats wild, never would have figured that that out
I ended up with this.

#SpyingonSPY
#Contains price point/value of "Mag 7, $ADSPD, $TIKUS, and $VOLSPD wether or not price is above or below previous bar close. depending on which chart is open will dictate the bar used in calculation. (Some data points wont start calculating until market open and stop at market close)

declare upper;
#input symbol = "$TIKUS";
#input symbol = "$ADSPD";
#input symbol2 = "MSFT";
#input symbol3 = "AAPL";
#input symbol4 = "AMZN";
#input symbol5 = "NVDA";
#input symbol6 = "GOOGL";
#input symbol7 = "META";
#input symbol8 = "TSLA";

#stating that if "current price for each symbol" is greater than "previous bar close" it is considered a "increase in price", and will be used in the price label coding to decide if the color will be red or green

def MyTIKUSvalue = close(symbol = "$TIKUS");
def isIncreasing8 = MyTIKUSvalue > MyTIKUSvalue[1];

def MyADSPDvalue = close(symbol = "$ADSPD");
def isIncreasing = MyADSPDvalue > MyADSPDvalue[1];

def MyVOLSPDvalue = close(symbol = "$VOLSPD");
def isIncreasing9 = MyVOLSPDvalue > MyVOLSPDvalue[1];


def MyMSFTprice = close(symbol = "MSFT");
def isIncreasing2 = MyMSFTprice > MyMSFTprice[1];

def MyAAPLprice = close(symbol = "AAPL");
def isIncreasing3 = MyAAPLprice > MyAAPLprice[1];

def MyAMZNprice = close(symbol = "AMZN");
def isIncreasing4 = MyAMZNprice > MyAMZNprice[1];

def MyNVDAprice = close(symbol = "NVDA");
def isIncreasing5 = MyNVDAprice > MyNVDAprice[1];

def MyGOOGLprice = close(symbol = "GOOGL");
def isIncreasing6 = MyGOOGLprice > MyGOOGLprice[1];

def MyMETAprice = close(symbol = "META");
def isIncreasing7 = MyMETAprice > MyMETAprice[1];

def MyTSLAprice = close(symbol = "TSLA");
def isIncreasing1 = MyTSLAprice > MyTSLAprice[1];


# Add a label with dynamic color based on previous bar close

#indicators

AddLabel(yes, "$TIKUS: " + MyTIKUSvalue, if isIncreasing8 then Color.GREEN else Color.RED);

AddLabel(yes, "$ADSPD: " + MyADSPDvalue, if isIncreasing then Color.GREEN else Color.RED);

AddLabel(yes, "$VOLSPD: " + MyVOLSPDvalue, if isIncreasing9 then Color.GREEN else Color.RED);

#stock symbols

AddLabel(yes, "MSFT: " + MyMSFTprice, if isIncreasing2 then Color.GREEN else Color.RED);

AddLabel(yes, "AAPL: " + MyAAPLprice, if isIncreasing3 then Color.GREEN else Color.RED);

AddLabel(yes, "AMZN: " + MyAMZNprice, if isIncreasing4 then Color.GREEN else Color.RED);

AddLabel(yes, "NVDA: " + MyNVDAprice, if isIncreasing5 then Color.GREEN else Color.RED);

AddLabel(yes, "GOOGL: " + MyGOOGLprice, if isIncreasing6 then Color.GREEN else Color.RED);

AddLabel(yes, "META: " + MyMETAprice, if isIncreasing7 then Color.GREEN else Color.RED);

AddLabel(yes, "TSLA: " + MyTSLAprice, if isIncreasing1 then Color.GREEN else Color.RED);
 
This is what your finished study looks like.
I included Comparison Studies that I recently completed for your benefit and/or further ideas:
https://usethinkscript.com/threads/...in-1-chart-for-thinkorswim.17409/#post-136149

The gray horizontal line is the Zero line for $TIKUS.

1705260542974.png
 
no thats just the start, im playing around with using tick count for the stocks so price direction will update faster than every one minute. I have a few other ideas to add to it as well, end game will be to use it as a reversal and scalping tool for the SPY
 
This is what your finished study looks like.
I included Comparison Studies that I recently completed for your benefit and/or further ideas:
https://usethinkscript.com/threads/...in-1-chart-for-thinkorswim.17409/#post-136149

The gray horizontal line is the Zero line for $TIKUS.

View attachment 20707
http://tos.mx/Mw38okJ SpyingOnSPYMag7 (Labels for MSFT, AAPLE, AMZN, NVDA, GOOGL, META, TSLA, green for increase in price, red for decrease in price, based of previous bar close. Will update based on chart time frame)
Ruby:
def MSFTPrice = close(symbol = "MSFT");
def isIncreasing = MSFTPrice > MSFTPrice[1];

def AAPLPrice = close(symbol = "AAPL");
def isIncreasing2 = AAPLPrice > AAPLPrice[1];

def AMZNPrice = close(symbol = "AMZN");
def isIncreasing3 = AMZNPrice > AMZNPrice[1];

def NVDAPrice = close(symbol = "NVDA");
def isIncreasing4 = NVDAPrice > NVDAPrice[1];

def GOOGLPrice = close(symbol = "GOOGL");
def isIncreasing5 = GOOGLPrice > GOOGLPrice[1];

def METAPrice = close(symbol = "META");
def isIncreasing6 = METAPrice > METAPrice[1];

def TSLAPrice = close(symbol = "TSLA");
def isIncreasing7 = TSLAPrice > TSLAPrice[1];


AddLabel(yes, "MSFT: " + MSFTPrice, if isIncreasing then Color.RED else Color.GREEN);
AddLabel(yes, "AAPL: " + AAPLPrice, if isIncreasing2 then Color.RED else Color.GREEN);
AddLabel(yes, "AMZN: " + AMZNPrice, if isIncreasing3 then Color.RED else Color.GREEN);
AddLabel(yes, "NVDA: " + NVDAPrice, if isIncreasing4 then Color.RED else Color.GREEN);
AddLabel(yes, "GOOGL: " + GOOGLPrice, if isIncreasing5 then Color.RED else Color.GREEN);
AddLabel(yes, "META: " + METAPrice, if isIncreasing6 then Color.RED else Color.GREEN);
AddLabel(yes, "TSLA: " + TSLAPrice, if isIncreasing7 then Color.RED else Color.GREEN);

http://tos.mx/BlmHOor SpyingOnSPY123 (is the staple of the indicators. Puts a Plethora of data onto one chart. As with the Mag7 green for up red for down. PUT, VIX, and /VX move inverse of SPY and are set to turn green if they are dropping in price and red if rising. PUT and CALL strike price must be updated manually in current version. I am using dailys ITM. It is done by clicking the "TRADE" tab , "ALL PRODUCTS" tab, Make sure stock ticker "SPY" is entered. Then open the "OPTION CHAIN." drop bar. I have filter: off Spread: single Layout: last x, Net change). Then find the current date for the Expiration date. Use what date you want i recommend dailys and/or weeklys. The tab(date) "22 jan 24" should be read as "options with a january 22, 2024 expiration."). Once the date is found open the tab, i set strikes to 50, find the calls (on left) and puts (on right). Scroll untill you see the shaded area split on right and left. that is where current market price lies. You want to make a copy of 1st In the money Call and Put. The Proper Call is the last row shaded on the left and the proper put is the 1st row shaded on the right. Right click the shaded cell of the bid or ask and click copy. then then do the same for the shaded cell bid or ask on the puts. and make a copy. Then open the indicator's coding and scroll to line 19. where it says ".SPY240124C475"); that is read as the SPY(SPY) call(C) option with a expiration date of January(01) the 24th(24) 2024(24) with a 475 strike price. Erase everything in between the " and " and paste the new option price in the coding. do the same for puts in line 22 of the coding. once this is entered for the day the last number is the only thing that needs changed in the call and put coding to keep it updated. for example, If i was tracking the daily option prices. (Options that expire today) and the current date was june 20th 2025 and SPY market price was somewhere between 475.00 and 476.00. then the daily call would read something like .SPY250620C475 and put would read .SPY250620P476. If price went up between 476.00 and 477.00 you can simply open the coding up and change .SPY250620C475 from line 19 in the coding to .SPY250620C476. and the put from .SPY250620P476 to .SPY250620P477. So once the daily put and call options are copied every morning the only thing that needs changed is one number to keep it updated. If price is within .20 of whole dollar it may be a good idea to use same strike price for put and call.)
the Idea of this indicator is to look for scalping opportunity confirmation at key levels such as FIB's, Prev HOD/LOD, Prev. Open/Close, MA's GAP's ect.
Ideally at these key locations the boxes should turn from red to green or green to red indicating strength in a reversal. Has not been tested, Im going to test it with the 1 minute chart tomorrow.
Ruby:
#SpyingonSPY
#Contains price point/value of "Mag 7, $ADSPD, $TIKUS, and $VOLSPD wether or not price is above or below previous bar close. depending on which chart is open will dictate the bar used in calculation. (Some data points wont start calculating until market open and stop at market close)


#input symbol = "$TIKUS";
#input symbol = "$ADSPD";
#input symbol2 = "MSFT";
#input symbol3 = "AAPL";
#input symbol4 = "AMZN";
#input symbol5 = "NVDA";
#input symbol6 = "GOOGL";
#input symbol7 = "META";
#input symbol8 = "TSLA";

#stating that if "current price for each symbol" is greater than "previous bar close" it is considered a "increase in price", and will be used in the price label coding to decide if the color will be red or green
declare upper;

#ATM option prices
def ATMCALLPRICE = close(symbol = ".SPY240124C475");
def isIncreasing12 = ATMCALLPRICE > ATMCALLPRICE[1];

def ATMPUTPRICE = close(symbol = ".SPY240124P476");
def isIncreasing13 = ATMPUTPRICE > ATMPUTPRICE[1];

#indicators
def MyTIKUSvalue = close(symbol = "$TIKUS");
def isIncreasing8 = MyTIKUSvalue > MyTIKUSvalue[1];

def MyADSPDvalue = close(symbol = "$ADSPD");
def isIncreasing = MyADSPDvalue > MyADSPDvalue[1];

def MyVOLSPDvalue = close(symbol = "$VOLSPD");
def isIncreasing9 = MyVOLSPDvalue > MyVOLSPDvalue[1];



#moves inverse of SPY
def VIXvalue = close(symbol = "VIX");
def isIncreasing10 = VIXvalue > VIXvalue[1];

def VXvalue = close(symbol = "/VX");
def isIncreasing11 = VXvalue > VXvalue[1];


# Add a label with dynamic color based on previous bar close


#ATM call and put prices

AddLabel(yes, "CALL: " + ATMCALLPRICE, if isIncreasing12 then Color.GREEN else Color.RED);

AddLabel(yes, "PUT: " + ATMPUTPRICE, if isIncreasing13 then Color.RED else Color.GREEN);

#indicators

AddLabel(yes, "$TIKUS: " + MyTIKUSvalue, if isIncreasing8 then Color.GREEN else Color.RED);

AddLabel(yes, "$ADSPD: " + MyADSPDvalue, if isIncreasing then Color.GREEN else Color.RED);

AddLabel(yes, "$VOLSPD: " + MyVOLSPDvalue, if isIncreasing9 then Color.GREEN else Color.RED);


#moves inverse of SPY

AddLabel(yes, "VIX: " + VIXvalue, if isIncreasing10 then Color.RED else Color.GREEN);
AddLabel(yes, "VX: " + VXvalue, if isIncreasing11 then Color.RED else Color.GREEN);


http://tos.mx/S8Rrat4 (this is nothing more than a relative volume indicator set at 1.5 of a 20 bar SMA. will turn from yellow to green if thresh hold is triggered)
Ruby:
input symbol = "AAPL";  # Default stock ticker is AAPL
input length = 20;

# Calculate average volume over a specified length
def averageVolume = MovingAverage(AverageType.SIMPLE, volume(symbol = symbol), length);

# Calculate relative volume
def relativeVolume = volume(symbol = symbol) / averageVolume;

# Add a label with dynamic color based on relative volume
AddLabel(yes, "Relative Volume (" + symbol + "): " + Round(relativeVolume, 2), color = if relativeVolume >= 1.5 then Color.GREEN else Color.YELLOW);

http://tos.mx/qyitp3T (this is the Option coding portion of SpyingOnSPY123 removed incase someone wanted to track weeklys along with dailys or try and update the code to automatically update as price moves. or update it to track the the 1st three strike prices in the money for puts and calls instead of just the 1st)
Ruby:
#ATM option prices
def ATMCALLPRICE = close(symbol = ".SPY240124C474");
def isIncreasing = ATMCALLPRICE > ATMCALLPRICE[1];

def ATMPUTPRICE = close(symbol = ".SPY240124P477");
def isIncreasing1 = ATMPUTPRICE > ATMPUTPRICE[1];

AddLabel(yes, "CALL: " + ATMCALLPRICE, if isIncreasing then Color.GREEN else Color.RED);
AddLabel(yes, "PUT: " + ATMPUTPRICE, if isIncreasing1 then Color.RED else Color.GREEN);
 
Last edited by a moderator:

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
393 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