middle of the first five-minute candle: Early S/R Line For ThinkOrSwim

BillW

Member
VIP
I've found some good S/R for NQ, ES, YM and 2K.
This script adapted from @SleepyZ https://usethinkscript.com/threads/high-low-range-within-specified-time.11836/post-113321 It plots support and resistance (S/R) levels starting from the beginning of the stock pre-market session (8:00 AM), through the first 5-minute candle and its midpoint. Extending these S/R lines from previous days can sometimes offer insights into potential levels for the current trading day. I’ve also added horizontal lines marking the regular trading hours (RTH) open and close from @korygill My reasoning is that pre-market activity in individual stocks can provide more reliable S/R levels than the opening range breakout (ORB) method typically used for selected indexes.

https://tos.mx/!kr0BVEMk

Screen Shot 09-24-25 at 04.29 PM.PNG



Code:
#Plots Hide and Low from 8:AM to 925:AM Globex (using 9.25 to close of candle at 9:30
#Adapted from SleepyZ https://usethinkscript.com/threads/high-low-range-within-specified-time.11836/post-113321
#Can be effective opening range for RTH S/R trading futures on 5 minute time frame.
#works with different time frames that start on the half hour such as 1, 5, 15 and 30.

def range  = SecondsFromTime(800) >= 0 and SecondsTillTime(930) >= 0;
def hrange = if range[1] == 0 and range
             then high
             else if range
             then Max(high, hrange[1])
             else hrange[1];
def lrange = if range[1] == 0 and range
             then low
             else if range
             then Min(low, lrange[1])
             else lrange[1];

input showplot = yes;
plot xhrange = if !showplot  then Double.NaN else hrange;
plot lhrange = if !showplot  then Double.NaN else lrange;

xhrange.SetDefaultColor(GetColor(1));
lhrange.SetDefaultColor(GetColor(5));

xhrange.SetStyle(curve.short_DASH);
lhrange.SetStyle(curve.short_DASH);

def is935 = SecondsFromTime(0930) == 0;
def isRTH = SecondsFromTime(0925) >= 0 and SecondsTillTime(1600) >= 0;

def midpoint = if is935 and isRTH then (high + low) / 2 else midpoint[1];

plot MidLine = if isRTH then midpoint else Double.NaN;
MidLine.SetDefaultColor(Color.yellow);
MidLine.SetStyle(Curve.short_Dash);


Horizontal Open


Code:
#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 930; # 24 hour time EST
input IntervalMinutes = 1440; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
         then nan
         else if IsNaN(Data)
         then tt[1]
         else if sft % (IntervalMinutes*60) == 0
         then Data
         else tt[1];


plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TimeTracker.SetDefaultColor(CreateColor(125, 125, 75));

TimeTracker.SetLineWeight(1);
TimeTracker.hidebubble();

Horizontal Close

Code:
#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 1615; # 24 hour time EST
input IntervalMinutes = 1440; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
         then nan
         else if IsNaN(Data)
         then tt[1]
         else if sft % (IntervalMinutes*60) == 0
         then Data
         else tt[1];


plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TimeTracker.SetDefaultColor(CreateColor(50, 160, 255));

TimeTracker.SetLineWeight(1);

timetracker.hidebubble();
 
Last edited by a moderator:
I've found some good S/R for NQ, ES, YM and 2K.
This script adapted from @SleepyZ https://usethinkscript.com/threads/high-low-range-within-specified-time.11836/post-113321 It plots support and resistance (S/R) levels starting from the beginning of the stock pre-market session (8:00 AM), through the first 5-minute candle and its midpoint. Extending these S/R lines from previous days can sometimes offer insights into potential levels for the current trading day. I’ve also added horizontal lines marking the regular trading hours (RTH) open and close from @korygill My reasoning is that pre-market activity in individual stocks can provide more reliable S/R levels than the opening range breakout (ORB) method typically used for selected indexes.

https://tos.mx/!kr0BVEMk

View attachment 25813


Code:
#Plots Hide and Low from 8:AM to 925:AM Globex (using 9.25 to close of candle at 9:30
#Adapted from SleepyZ https://usethinkscript.com/threads/high-low-range-within-specified-time.11836/post-113321
#Can be effective opening range for RTH S/R trading futures on 5 minute time frame.
#works with different time frames that start on the half hour such as 1, 5, 15 and 30.

def range  = SecondsFromTime(800) >= 0 and SecondsTillTime(930) >= 0;
def hrange = if range[1] == 0 and range
             then high
             else if range
             then Max(high, hrange[1])
             else hrange[1];
def lrange = if range[1] == 0 and range
             then low
             else if range
             then Min(low, lrange[1])
             else lrange[1];

input showplot = yes;
plot xhrange = if !showplot  then Double.NaN else hrange;
plot lhrange = if !showplot  then Double.NaN else lrange;

xhrange.SetDefaultColor(GetColor(1));
lhrange.SetDefaultColor(GetColor(5));

xhrange.SetStyle(curve.short_DASH);
lhrange.SetStyle(curve.short_DASH);

def is935 = SecondsFromTime(0930) == 0;
def isRTH = SecondsFromTime(0925) >= 0 and SecondsTillTime(1600) >= 0;

def midpoint = if is935 and isRTH then (high + low) / 2 else midpoint[1];

plot MidLine = if isRTH then midpoint else Double.NaN;
MidLine.SetDefaultColor(Color.yellow);
MidLine.SetStyle(Curve.short_Dash);


Horizontal Open


Code:
#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 930; # 24 hour time EST
input IntervalMinutes = 1440; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
         then nan
         else if IsNaN(Data)
         then tt[1]
         else if sft % (IntervalMinutes*60) == 0
         then Data
         else tt[1];


plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TimeTracker.SetDefaultColor(CreateColor(125, 125, 75));

TimeTracker.SetLineWeight(1);
TimeTracker.hidebubble();

Horizontal Close

Code:
#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 1615; # 24 hour time EST
input IntervalMinutes = 1440; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
         then nan
         else if IsNaN(Data)
         then tt[1]
         else if sft % (IntervalMinutes*60) == 0
         then Data
         else tt[1];


plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TimeTracker.SetDefaultColor(CreateColor(50, 160, 255));

TimeTracker.SetLineWeight(1);

timetracker.hidebubble();
Very interesting. Is there any way to create an indicator that provides a choice of the mid-point for the first 5 minutes, the first 15 minutes, the first 30 minutes, and the first hour. It's not necessary for one indicator to do all of that but rather to create an indicator that can be changed for the desired period of time to use as the beginning range.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
270 Online
Create Post

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