Distance from Premarket High Watchlist


Category:
0
0

Hi Pete,

Thank you for all the helpful studies, alerts, and watchlists. I did some searching and found the following: https://www.hahn-tech.com/ans/distance-from-high-of-day-watchlist/

I was wondering if you could help provide the thinkscript code for a watchlist column which changes color when regular market hours are approaching (within 5%) the current day Premarket high. It would work similar to the link above but would look for premarket highs instead of regular hour highs. Thank you so much for your time.

RESOLVED
Marked as spam
Posted by (Questions: 3, Answers: 3)
Asked on July 10, 2018 12:35 am
534 views
0

Just checking before I get started on this. You specifically want to exclude the after market hours of the previous day? Which means rather than the high from the extended hours session you only want to use the high from the current day’s premarket trade.

( at July 10, 2018 7:55 am)
0
I only want to use the high from the current day’s premarket trade. Please do not include the aftermarket hours of the previous day. Thank you!
( at July 10, 2018 10:40 am)
0
Private answer

This one required some additional effort to deal with the request to split the extended hours trading session to include only the premarket data. I had to do this in stages in order to capture the first bar of premarket but exclude regular session and aftermarket hours.

The next challenge was to find a list of stocks that had moved more than +/- 5% from premarket highs. In the screenshot below we see the tickers shaded in white are less than +/- 5% from premarket high. The ones in black are greater than this threshold.

Here is the code:

input percentThreshold = 5.0;
def stageOne = RegularTradingEnd(GetYYYYMMDD());
def premarketStart = stageOne[1] <> stageOne;
def stageTwo = SecondsTillTime(930);
def premarketSession = stageTwo > 0;
rec premarketHigh = if premarketStart and premarketSession then high else if high > premarketHigh[1] and premarketSession then high else premarketHigh[1];
plot percentFromPremarketHigh = 100 * (close / premarketHigh - 1);
percentFromPremarketHigh.AssignValueColor(if AbsValue(percentFromPremarketHigh) < percentThreshold then Color.BLACK else Color.CURRENT);
AssignBackgroundColor(if AbsValue(percentFromPremarketHigh) < percentThreshold then Color.WHITE else Color.CURRENT);

 

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on July 11, 2018 10:03 am
0
I’m unsure why but when adding the code, every column reads infinity. EDIT: I believe this is because of the time period. Thanks Pete.
( at July 11, 2018 12:46 pm)
0

Yes, you will need to apply this to an intraday time frame and be sure to check the box for extended hours.

( at July 11, 2018 3:38 pm)