#### 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;

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

Solution
Remove " \$ ":

Remove " \$ ":

Remove " \$ ":

Thats wild, never would have figured that that out

Remove " \$ ":

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 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 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, "\$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:

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

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:

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

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 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 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, "\$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:

87k+ Posts
179 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?