Premarket high low for different tickers

Terry88888

New member
Hi, this is my first post here. I trade QQQ most of the time and the main chart I watch is QQQ's 5min chart, where I plot the premarket high low as key price levels (see chart). In the meantime, I would like to know how SPY, DIA, and IWM trade with respect to their own premarket highs lows and want to use these as confirmation for QQQ. I use the following code to get premarket high low for QQQ (the current ticker):

#========Begin premarket high low (for the current ticker)========
input start = 0930;
input end = 1600;
def p1 = (SecondsFromTime(end) >= 0 and SecondsTillTime(2359) > 0);
def p2 = (SecondsFromTime(0000) >= 0 and SecondsTillTime(start) > 0);
#def pretime = p1 or p2;
def pretime = p2;
def prehi = if !pretime[1] and pretime then high
else if pretime and high > prehi[1] then high
else prehi[1];
def prelo = if !pretime[1] and pretime then low
else if pretime and low < prelo[1] then low
else prelo[1];
AddLabel(yes, "PMH=" + prehi + ", " + "PML=" + prelo, Color.WHITE);
#========End premarket high low (for the current ticker)========

After I modified the above code for a different ticker as follows, it didn't give me any results and there was no error messages . Can someone please help me with this? Thanks very much in advance!!!
#========Begin premarket high low (for a different ticker)========
script PM {
input ticker = "SPY";
input start = 0930;
input end = 1600;
def p1 = (SecondsFromTime(end) >= 0 and SecondsTillTime(2359) > 0);
def p2 = (SecondsFromTime(0000) >= 0 and SecondsTillTime(start) > 0);
#def pretime = p1 or p2;
def pretime = p2;
def prehi = if !pretime[1] and pretime then high(ticker)
else if pretime and high(ticker) > prehi[1] then high(ticker)
else prehi[1];
def prelo = if !pretime[1] and pretime then low(ticker)
else if pretime and low(ticker) < prelo[1] then low(ticker)
else prelo[1];
}
AddLabel(yes, "PMH_SPY" + PM("SPY").prehi + ", " + "PML_SPY" + PM("SPY").prelo, Color.WHITE);
AddLabel(yes, "PMH_DIA" + PM("DIA").prehi + ", " + "PML_DIA" + PM("DIA").prelo, Color.WHITE);
AddLabel(yes, "PMH_IWM" + PM("IWM").prehi + ", " + "PML_IWM" + PM("IWM").prelo, Color.WHITE);
#========End premarket high low (for a different ticker)========

1685370410745.png
 
Hi, this is my first post here. I trade QQQ most of the time and the main chart I watch is QQQ's 5min chart, where I plot the premarket high low as key price levels (see chart). In the meantime, I would like to know how SPY, DIA, and IWM trade with respect to their own premarket highs lows and want to use these as confirmation for QQQ. I use the following code to get premarket high low for QQQ (the current ticker):

#========Begin premarket high low (for the current ticker)========
input start = 0930;
input end = 1600;
def p1 = (SecondsFromTime(end) >= 0 and SecondsTillTime(2359) > 0);
def p2 = (SecondsFromTime(0000) >= 0 and SecondsTillTime(start) > 0);
#def pretime = p1 or p2;
def pretime = p2;
def prehi = if !pretime[1] and pretime then high
else if pretime and high > prehi[1] then high
else prehi[1];
def prelo = if !pretime[1] and pretime then low
else if pretime and low < prelo[1] then low
else prelo[1];
AddLabel(yes, "PMH=" + prehi + ", " + "PML=" + prelo, Color.WHITE);
#========End premarket high low (for the current ticker)========

After I modified the above code for a different ticker as follows, it didn't give me any results and there was no error messages . Can someone please help me with this? Thanks very much in advance!!!
#========Begin premarket high low (for a different ticker)========
script PM {
input ticker = "SPY";
input start = 0930;
input end = 1600;
def p1 = (SecondsFromTime(end) >= 0 and SecondsTillTime(2359) > 0);
def p2 = (SecondsFromTime(0000) >= 0 and SecondsTillTime(start) > 0);
#def pretime = p1 or p2;
def pretime = p2;
def prehi = if !pretime[1] and pretime then high(ticker)
else if pretime and high(ticker) > prehi[1] then high(ticker)
else prehi[1];
def prelo = if !pretime[1] and pretime then low(ticker)
else if pretime and low(ticker) < prelo[1] then low(ticker)
else prelo[1];
}
AddLabel(yes, "PMH_SPY" + PM("SPY").prehi + ", " + "PML_SPY" + PM("SPY").prelo, Color.WHITE);
AddLabel(yes, "PMH_DIA" + PM("DIA").prehi + ", " + "PML_DIA" + PM("DIA").prelo, Color.WHITE);
AddLabel(yes, "PMH_IWM" + PM("IWM").prehi + ", " + "PML_IWM" + PM("IWM").prelo, Color.WHITE);
#========End premarket high low (for a different ticker)========

View attachment 18779

the output of a script {} comes from a plot command. you don't have any.
sometimes plot formulas don't like recursive data. i would leave your last 2 formulas as def, but change their variable names. then add plots.

i would change the name of your def variables, from,
prehi to prehi2
prelo to prelo2

def prehi2 = if !pretime[1] and...
def prelo2 = if !pretime[1] and...

then add plot variables, using the desired names

plot prehi = prehi2;
plot prelo = prelo2;
}

https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/script
 

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