# TOS Indicator: Weekly And After-Hours/Pre-Market Highs And Lows

#### ganq

##### Member
2019 Donor
Hi,

Is there an indicator for TOS which will paint the high and low price for a security for the last 7 days excluding after-hours and pre-market?

And a similar one which will paint the high and low from after-hours and pre-market (1 day before) before the market opens?

Would appreciate if someone could point me towards an indicator like this or if a similar one is available I could try my hand on Think Script.

I believe, knowing the highs and lows for the last 7 days could give us some valuable support and resistance lines.

Thank you!

Solution
See if this dos what you want.

Code:
``````    #High and Lows per day for last 10 days on chart
#   Put together by Horserider
input painthigh = 4;#Hint painthigh: 1=dots,2=dashes,3=squares,4=horizontal
def paintingStrategyhigh = if painthigh == 1 then PaintingStrategy.POINTS else if painthigh == 4 then PaintingStrategy.DASHES else if painthigh == 3 then PaintingStrategy.SQUARES else PaintingStrategy.HORIZONTAL;
input paintlow = 4; #Hint paintlow: 1=dots,2=dashes,3=squares,4=horizontal
def paintingStrategylow = if paintlow == 1 then PaintingStrategy.POINTS else if paintlow == 2 then PaintingStrategy.DASHES else if paintlow == 3 then PaintingStrategy.SQUARES else PaintingStrategy.HORIZONTAL;
rec high1 = if GetDay() == GetLastDay() then...``````
See if this dos what you want.

Code:
``````    #High and Lows per day for last 10 days on chart
#   Put together by Horserider
input painthigh = 4;#Hint painthigh: 1=dots,2=dashes,3=squares,4=horizontal
def paintingStrategyhigh = if painthigh == 1 then PaintingStrategy.POINTS else if painthigh == 4 then PaintingStrategy.DASHES else if painthigh == 3 then PaintingStrategy.SQUARES else PaintingStrategy.HORIZONTAL;
input paintlow = 4; #Hint paintlow: 1=dots,2=dashes,3=squares,4=horizontal
def paintingStrategylow = if paintlow == 1 then PaintingStrategy.POINTS else if paintlow == 2 then PaintingStrategy.DASHES else if paintlow == 3 then PaintingStrategy.SQUARES else PaintingStrategy.HORIZONTAL;
rec high1 = if GetDay() == GetLastDay() then high(period = AggregationPeriod.DAY) else high1[1];
input colorhigh = 1;#Hint colorhigh: 0=magenta,1=cyan,2=light-red,3=light_green,4=yellow,5=red,6=green,7=light_gray,8=gold,9=white
input colorlow = 1;#Hint colorlow: 0=magenta,1=cyan,2=light-red,3=light_green,4=yellow,5=red,6=green,7=light_gray,8=gold,9=white

plot h1 = high1;

h1.SetPaintingStrategy(paintingStrategyhigh);
h1.SetDefaultColor(GetColor(colorhigh));

rec high2 = if GetDay() == GetLastDay() - 1 then high(period = AggregationPeriod.DAY) else high2[1];
plot h2 = high2;
h2.SetPaintingStrategy(paintingStrategyhigh);
h2.SetDefaultColor(GetColor(colorhigh));
rec high3 = if GetDay() == GetLastDay() - 2 then high(period = AggregationPeriod.DAY) else high3[1];
plot h3 = high3;
h3.SetPaintingStrategy(paintingStrategyhigh);
h3.SetDefaultColor(GetColor(colorhigh));
rec high4 = if GetDay() == GetLastDay() - 3 then high(period = AggregationPeriod.DAY) else high4[1];
plot h4 = high4;
h4.SetPaintingStrategy(paintingStrategyhigh);
h4.SetDefaultColor(GetColor(colorhigh));
rec high5 = if GetDay() == GetLastDay() - 4 then high(period = AggregationPeriod.DAY) else high5[1];
plot h5 = high5;
h5.SetPaintingStrategy(paintingStrategyhigh);
h5.SetDefaultColor(GetColor(colorhigh));
rec high6 = if GetDay() == GetLastDay() - 5 then high(period = AggregationPeriod.DAY) else high6[1];
plot h6 = high6;
h6.SetPaintingStrategy(paintingStrategyhigh);
h6.SetDefaultColor(GetColor(colorhigh));
rec high7 = if GetDay() == GetLastDay() - 6 then high(period = AggregationPeriod.DAY) else high7[1];
plot h7 = high7;
h7.SetPaintingStrategy(paintingStrategyhigh);
h7.SetDefaultColor(GetColor(colorhigh));
rec high8 = if GetDay() == GetLastDay() - 7 then high(period = AggregationPeriod.DAY) else high8[1];
plot h8 = high8;
h8.SetPaintingStrategy(paintingStrategyhigh);
h8.SetDefaultColor(GetColor(colorhigh));
rec high9 = if GetDay() == GetLastDay() - 8 then high(period = AggregationPeriod.DAY) else high9[1];
plot h9 = high9;
h9.SetPaintingStrategy(paintingStrategyhigh);
h9.SetDefaultColor(GetColor(colorhigh));
rec high10 = if GetDay() == GetLastDay() - 9 then high(period = AggregationPeriod.DAY) else high10[1];
plot h10 = high10;
h10.SetPaintingStrategy(paintingStrategyhigh);
h10.SetDefaultColor(GetColor(colorhigh));
rec high11 = if GetDay() == GetLastDay() - 10 then high(period = AggregationPeriod.DAY) else high11[1];
plot h11 = high11;
h11.SetPaintingStrategy(paintingStrategyhigh);
h11.SetDefaultColor(GetColor(colorhigh));
rec high12 = if GetDay() == GetLastDay() - 11 then high(period = AggregationPeriod.DAY) else high12[1];
plot h12 = high12;
h12.SetPaintingStrategy(paintingStrategyhigh);
h12.SetDefaultColor(GetColor(colorhigh));
rec high13 = if GetDay() == GetLastDay() - 12 then high(period = AggregationPeriod.DAY) else high13[1];
plot h13 = high13;
h13.SetPaintingStrategy(paintingStrategyhigh);
h13.SetDefaultColor(GetColor(colorhigh));
rec high14 = if GetDay() == GetLastDay() - 13 then high(period = AggregationPeriod.DAY) else high14[1];
plot h14 = high14;
h14.SetPaintingStrategy(paintingStrategyhigh);
h14.SetDefaultColor(GetColor(colorhigh));
rec high15 = if GetDay() == GetLastDay() - 14 then high(period = AggregationPeriod.DAY) else high15[1];
plot h15 = high15;
h15.SetPaintingStrategy(paintingStrategyhigh);
h15.SetDefaultColor(GetColor(colorhigh));

rec low1 = if GetDay() == GetLastDay() then low(period = AggregationPeriod.DAY) else low1[1];
plot l1 = low1;
l1.SetPaintingStrategy(paintingStrategylow);
l1.SetDefaultColor(GetColor(colorlow));
rec low2 = if GetDay() == GetLastDay() - 1 then low(period = AggregationPeriod.DAY) else low2[1];
plot l2 = low2;
l2.SetPaintingStrategy(paintingStrategylow);
l2.SetDefaultColor(GetColor(colorlow));
rec low3 = if GetDay() == GetLastDay() - 2 then low(period = AggregationPeriod.DAY) else low3[1];
plot l3 = low3;
l3.SetPaintingStrategy(paintingStrategylow);
l3.SetDefaultColor(GetColor(colorlow));
rec low4 = if GetDay() == GetLastDay() - 3 then low(period = AggregationPeriod.DAY) else low4[1];
plot l4 = low4;
l4.SetPaintingStrategy(paintingStrategylow);
l4.SetDefaultColor(GetColor(colorlow));
rec low5 = if GetDay() == GetLastDay() - 4 then low(period = AggregationPeriod.DAY) else low5[1];
plot l5 = low5;
l5.SetPaintingStrategy(paintingStrategylow);
l5.SetDefaultColor(GetColor(colorlow));
rec low6 = if GetDay() == GetLastDay() - 5 then low(period = AggregationPeriod.DAY) else low5[1];
plot l6 = low6;
l6.SetPaintingStrategy(paintingStrategylow);
l6.SetDefaultColor(GetColor(colorlow));
rec low7 = if GetDay() == GetLastDay() - 6 then low(period = AggregationPeriod.DAY) else low7[1];
plot l7 = low7;
l7.SetPaintingStrategy(paintingStrategylow);
l7.SetDefaultColor(GetColor(colorlow));
rec low8 = if GetDay() == GetLastDay() - 7 then low(period = AggregationPeriod.DAY) else low8[1];
plot l8 = low8;
l8.SetPaintingStrategy(paintingStrategylow);
l8.SetDefaultColor(GetColor(colorlow));
rec low9 = if GetDay() == GetLastDay() - 8 then low(period = AggregationPeriod.DAY) else low9[1];
plot l9 = low9;
l9.SetPaintingStrategy(paintingStrategylow);
l9.SetDefaultColor(GetColor(colorlow));
rec low10 = if GetDay() == GetLastDay() - 9 then low(period = AggregationPeriod.DAY) else low10[1];
plot l10 = low10;
l10.SetPaintingStrategy(paintingStrategylow);
l10.SetDefaultColor(GetColor(colorlow));
rec low11 = if GetDay() == GetLastDay() - 10 then low(period = AggregationPeriod.DAY) else low11[1];
plot l11 = low11;
l11.SetPaintingStrategy(paintingStrategylow);
l11.SetDefaultColor(GetColor(colorlow));
rec low12 = if GetDay() == GetLastDay() - 11 then low(period = AggregationPeriod.DAY) else low12[1];
plot l12 = low12;
l12.SetPaintingStrategy(paintingStrategylow);
l12.SetDefaultColor(GetColor(colorlow));
rec low13 = if GetDay() == GetLastDay() - 12 then low(period = AggregationPeriod.DAY) else low13[1];
plot l13 = low13;
l13.SetPaintingStrategy(paintingStrategylow);
l13.SetDefaultColor(GetColor(colorlow));
rec low14 = if GetDay() == GetLastDay() - 13 then low(period = AggregationPeriod.DAY) else low14[1];
plot l14 = low14;
l14.SetPaintingStrategy(paintingStrategylow);
l14.SetDefaultColor(GetColor(colorlow));
rec low15 = if GetDay() == GetLastDay() - 14 then low(period = AggregationPeriod.DAY) else low15[1];
plot l15 = low15;
l15.SetPaintingStrategy(paintingStrategylow);
l15.SetDefaultColor(GetColor(colorlow));``````

@horserider Thank you so much, will try it tonight once I get home. I added the above Study to TOS and looked at Apple on the 20 D 5 Min Chart but everything got squished, please advise.

@ganq The issue you're faced with is that there are too many lines on the chart that are close together. A quick fix is to go to Chart Settings > Price Axis and turn off "Fit studies" and "Fit study markers"

Does anyone have an indicator that marks a line at the after hours high, not the pre market?

I'm looking for the same; did you ever find one?

Does anyone have an indicator that marks a line at the after hours high, not the pre market?
I'm looking for the same; did you ever find one?
You can unplot any lines that you don't want.

I'm looking for the same; did you ever find one?
Was also looking for the same but couldnt find it, so ended up having to write it : )...

See below link to TradingView pinescript 'AfterHours Spike Detector' indicator. It shows afterhours (post-market and next day pre-market) High/Lows on a Daily regular session chart, and significant afterhours price changes / spikes (e.g. >10%).

Indicator - AfterHours Spike Detector

87k+ Posts
267 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?