Please help me figure out this possible ToS glitch

jonesjb

New member
VIP
I created a simple study referencing SPY to show the close price on another chart. Here is the script:

plot altPrice = close ("SPY");

When I display this study on another ticker's price chart (QQQ), it displays gaps within the blue line in the lower area (which I believe indicates that it's registering the parameter as Not a Number for those time intervals, i.e. IsNaN).

You can see what I'm referring to by looking at the gaps in the blue line in the study in the lower area:

1697013562344.png


However when I display the same study with SPY in the upper Price area. it functions formally, what the heck is going on here? The gaps disappear!! I can't figure it out as the study is linked to "SPY" and shouldn't be contingent on what ticker is in the upper area.

1697013636272.png


'displays gaps, Not a Number'
neither chart is displaying numbers. they are displaying blue lines.

'Note the blue gaps in the link in the study in the lower area:'
there are no blue gaps. there are gaps in a blue line.

you need practice in writing what you see.
efficient communication results in more accurate answers.

--------

not all stocks have trades during the same time periods, especially in after hours. no trades, no candle. no candle, no price data to read.
@halcyonguy yes, you are correct, your feedback is fair. I re-read what I wrote, and I could have been clearer. I've gone back and edited my post which hopefully makes my question more specific as to what I'm asking.

Would you or anyone else be able to answer?

You said: “not all stocks have trades during the same time periods, especially in after hours. no trades, no candle. no candle, no price data to read.”

As I understand, both blue lines should be showing the same SPY close data. If the line is continuous without any gaps for the second image, shouldn’t it be the same for the first image? When I identified a gap in the first chart, I then checked the second chart to verify whether there were SPY trades for the time period, and I was able to verify that there is indeed a trade for the time period.
 
Last edited by a moderator:
Solution
I created a simple study referencing SPY to show the close price on another chart. Here is the script:

plot altPrice = close ("SPY");

When I display this study on another ticker's price chart (QQQ), it displays gaps within the blue line in the lower area (which I believe indicates that it's registering the parameter as Not a Number for those time intervals, i.e. IsNaN).

You can see what I'm referring to by looking at the gaps in the blue line in the study in the lower area:

View attachment 19888

However when I display the same study with SPY in the upper Price area. it functions formally, what the heck is going on here? The gaps disappear!! I can't figure it out as the study is linked to "SPY" and shouldn't be contingent on what ticker...
I created a simple study referencing SPY to show the close price on another chart. Here is the script:

plot altPrice = close ("SPY");

When I display this study on another ticker's price chart (QQQ), it displays gaps within the blue line in the lower area (which I believe indicates that it's registering the parameter as Not a Number for those time intervals, i.e. IsNaN).

You can see what I'm referring to by looking at the gaps in the blue line in the study in the lower area:

View attachment 19888

However when I display the same study with SPY in the upper Price area. it functions formally, what the heck is going on here? The gaps disappear!! I can't figure it out as the study is linked to "SPY" and shouldn't be contingent on what ticker is in the upper area.

View attachment 19889


@halcyonguy yes, you are correct, your feedback is fair. I re-read what I wrote, and I could have been clearer. I've gone back and edited my post which hopefully makes my question more specific as to what I'm asking.

Would you or anyone else be able to answer?

You said: “not all stocks have trades during the same time periods, especially in after hours. no trades, no candle. no candle, no price data to read.”

As I understand, both blue lines should be showing the same SPY close data. If the line is continuous without any gaps for the second image, shouldn’t it be the same for the first image? When I identified a gap in the first chart, I then checked the second chart to verify whether there were SPY trades for the time period, and I was able to verify that there is indeed a trade for the time period.

TOS will only display data from the secondary symbol if that data matches the exact bar times on the primary symbol. So we use a recursive (the last real data) to fill the mismatched times. We often also use the recursive to extend lines into the right expansion.

The upper lower image shows the recursive code below. The lower lower image is your code. You can see how the recursive fills in the line and then extends it as a straight line on the right edge.

Screenshot 2023-10-11 223440.png
Code:
def spy_close = if isnan(close ("SPY")) then spy_close[1] else close ("SPY");
plot altPrice = spy_close;
 
Solution
TOS will only display data from the secondary symbol if that data matches the exact bar times on the primary symbol. So we use a recursive (the last real data) to fill the mismatched times. We often also use the recursive to extend lines into the right expansion.

The upper lower image shows the recursive code below. The lower lower image is your code. You can see how the recursive fills in the line and then extends it as a straight line on the right edge.
Ah, this makes a lot of sense, thank you or clearing this up for me. I appreciate it!
 

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