Previous day close to current intraday close


Category:
0
0

Hello can you help me with the script it shows change during market hours is that possible to have extended hours also show up

input SYMB = “SPY”;
def AD = close (symbol = SYMB, period = AggregationPeriod.day) – close(symbol = SYMB, period = AggregationPeriod.day)[1];
AddLabel(yes, “SPY” + ”: ” + AD, if AD >= -.30 then Color.White else Color.red);

Marked as spam
Posted by (Questions: 12, Answers: 5)
Asked on September 25, 2019 4:17 pm
67 views
0
The question title: "include extended hours" is far to vague. This could apply to any one of a dozen posts in the forum. We need to make sure other visitors to the forum are able to search for this solution. More importantly, they need to be able to read through a list of hundreds of posts and immediately know the context of this one. So I will change the title of this post to: "previous day close to current intraday close"
( at September 26, 2019 9:36 am)
0
Private answer

Your existing code is written so that it reads the close from the daily aggregation period and from a ticker symbol other than the ticker symbol applied to the chart. This is used on an intraday chart to compute the difference between yesterday's close and today's close on the daily time frame for the ticker symbol selected via the user input named "SYMB". This is the line of code that reads from the daily time frame:

def AD = close (symbol = SYMB, period = AggregationPeriod.day) – close(symbol = SYMB, period = AggregationPeriod.day)[1];

Your request is to convert this code so that "...extended hours also so up.". Which means you need to remove the secondary aggregation from a portion of this code. To accomplish this we will leave the second part of code to remain as is, reading from daily time frame to get the previous day close of the selected symbol.

close(symbol = SYMB, period = AggregationPeriod.day)[1]

Then we change the first portion of the code to something that will read the current close (of the selected symbol) during extended hours and regular session hours.

close(symbol = SYMB)

This is what is looks like after we make this adjustment:

def AD = close (symbol = SYMB) – close(symbol = SYMB, period = AggregationPeriod.DAY)[1];

We put this altogether and we have the following result:

input tickerSymbol = “SPY”;
def netDailyChange = close (symbol = tickerSymbol) – close(symbol = tickerSymbol, period = AggregationPeriod.DAY)[1];
AddLabel(yes, “SPY: ” + netDailyChange, if netDailyChange >= -0.30 then Color.WHITE else Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on September 26, 2019 10:01 am