Premarket hours to current % Change


Category:
0
0

Hi Pete,

 

Thank you for the helpful studies. I currently have this one liner which is used to capture % change for a single day.

def pc = Round(100*((close/open(period = AggregationPeriod.DAY))-1),1);

I would like for it to only capture %change from current day premarket to current time. Would really appreciate your help in achieving this. Thank you kindly.

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on December 13, 2018 10:03 pm
130 views
0

For stocks with high premarket activity, is the close of the premarket really any different than the open of the regular session? I don’t know, because I don’t follow this. Just asking. That is what you wanted right? The closing price of the premarket, as compared to the current price of the regular session?

( at December 14, 2018 7:45 am)
0

The problem with the current 1 liner is that it only provides data when market opens. I’d like for the data to include the data from premarket as well. Similar to how the mark%change watchlist works. Thanks for the response.

( at December 14, 2018 9:28 am)
0

Ok, the reason it does not work until market is open is because the code is reading from today’s market open. It’s taking the current price and dividing it by today’s regular session open. During premarket hours, the data is not available, because it hasn’t happened yet.

So what you have here is a value that compares today’s regular session open to current intraday price. In order to have this compute a value during premarket hours, you will need to tell me what data point to use in place of today’s regular session open.

( at December 14, 2018 10:57 am)
0

Thanks for the clarification.

I would like to use the premarket session open (4am ET) as the data point. 

( at December 14, 2018 11:33 am)
0
Private answer

After getting some clarification we have a solution. This uses the premarket opening price and compares that to the current price, and expresses a percentage change value.

Important note. This code will fail for stocks that do not have any trade data at exactly 4pm Eastern.

def start = SecondsTillTime(400) == 0;
rec premarketOpen = if start then open else premarketOpen[1];
def percentChange = Round(100 * ((close / premarketOpen) - 1), 1);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on December 15, 2018 10:25 am
0

Hi Pete,

I tested the script and I’m not receiving the results I was expecting. The final result is showing a very large number instead of a percentage.

( at December 16, 2018 1:37 pm)
0

I tested it on mine and it is giving percentage values. I only copied the exact math used in your original source code. So the math is exactly what you had before. Check that you didn’t modify something when applying it to your test.

( at December 17, 2018 7:51 am)
0

Did you miss my note? “Important note. This code will fail for stocks that do not have any trade data at exactly 4pm Eastern.”

( at December 17, 2018 11:06 am)