Prior Day High Low

JoseyWales

New member
VIP
I want to determine if there is a gap in the overnight trading so I need to refer back to the previous days high and low.

I started with code for tracking the opening range and changed the time to be the entire session, 930 - 1600.

I changed the plot function to draw the lines but I can't figure out how to get the previous high or low so I can write a formula

Gap = close > PDHigh or Close < PDLow

Any help would be great.
Thanks

1731358106987.png


Code:
# 10-31-24 Rich HIGH/LOW of RTH
# Some code By Prospectus @ http://readtheprospectus.wordpress.com
# Inspired by Trader-X @ http://traderx.blogspot.com
#
# Originally This Thinkscript is designed to plot the OR high, low,
# 50% fib retrace, and fib extensions for the current day.
# This will only work correctly on time-based charts,
# where the OR timeframe is divisible by the bar period
# e.g. 30 minute OR, 10 min bars. An extra fib extension
# may be used if desired to create a target zone.
#
def na = Double.NaN;
#
# Define time that OR begins (in hhmm format,
# 0930 is the default):
#
input ORBegin = 0930;
#
# Define time that OR is finished (in hhmm format,
# 10:00 is the default):
#
input OREnd = 1600;
#

#
# Show Today only? (Default Yes)
#
input ShowTodayOnly = {"No", default "Yes"};
def s = ShowTodayOnly;
#

#
# Create logic for OR definition:
#
def ORActive = if SecondsTillTime(OREnd) > 0 and SecondsFromTime(ORBegin) >= 0 then 1 else 0;
#
# Create logic to paint only current day post-open:
#
def today = if s == 0 or GetDay() == GetLastDay() and SecondsFromTime(ORBegin) >= 0 then 1 else 0;
#
# Track OR High:
#
rec ORHigh = if ORHigh[1] == 0 or ORActive[1] == 0 and ORActive == 1 then high else if ORActive and high > ORHigh[1] then high else ORHigh[1];
#
# Track OR Low:
#
rec ORLow = if ORLow[1] == 0 or ORActive[1] == 0 and ORActive == 1 then low else if ORActive and low < ORLow[1] then low else ORLow[1];

#################################################

#How to save previous days high/low?

def DayEnd = SecondsTillTime(OREnd) < 0;

#if DayEnd then ORHigh = PD_High  else na ;


#def PD_High= ORHighLine;


def MarketOpenBar = SecondsFromTime(ORBegin) >= 0 and SecondsFromTime(ORBegin) < 1;
def MarketOpen = if MarketOpenBar then open else na;

plot MarketOpenPrice = MarketOpen;

#def PD_High = if MarketOpen then ORHigh[1] else na;
#def PD_Low = if MarketOpen then ORLow[1] else na;

#plot GapU = PD_High;
#plot GapD = PD_Low;

 #addverticalLine(shouldDraw, "London Open at " + timeToDrawLine, getColor(lineColor), Curve.SHORT_DASH);

#AddVerticalLine(MarketOpen, "Open ", Color.CYAN, Curve.SHORT_DASH);
#
# Define all the plots:
#
plot ORL = ORLow;
plot ORH = ORHigh;

#
# Formatting:
#
ORH.SetDefaultColor(Color.GREEN);
ORH.SetStyle(Curve.LONG_DASH);
ORH.SetLineWeight(3);
ORL.SetDefaultColor(Color.RED);
ORL.SetStyle(Curve.LONG_DASH);
ORL.SetLineWeight(3);

#labels
AddLabel (yes, orlow, color.red);

AddLabel (yes, orh, CreateColor(127,255,0));
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
466 Online
Create Post

Similar threads

Similar threads

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