# Plot Lowest Low AFTER Intraday High

#### daven

##### New member
I am working on a TOS script for a scanner and stuck on Retrieving the Lowest low within a specified period after Highest High is captured in the specified period, please see code below: Will appreciate help in obtaining lowAfterHigh

input periodStartEST = 0930;
input periodEndEST = 1200;

# Define some variables to identify the start and end of the period
def periodStart = if secondsTillTime(periodStartEST) <=0 and secondsTillTime(periodStartEST)[1] > 0 then 1 else 0;
def periodEnd = if secondsTillTime(periodEndEST) <=0 and secondsTillTime(periodEndEST)[1] > 0 then 1 else 0;

# Define variables to identify the period as a whole
def inPeriod = if periodStart then 1 else if periodEnd then 0 else inPeriod[1];
def newPeriod = if periodStart then 1 else 0;

# Capture the high, low, and open only within the period. Reset when a new period starts
def highOfPeriod = if newPeriod then high else if inPeriod then if high > highOfPeriod[1] then high else highOfPeriod[1] else highOfPeriod[1];
def lowOfPeriod = if newPeriod then low else if inPeriod then if low < lowOfPeriod[1] then low else lowOfPeriod[1] else lowOfPeriod[1];
def openOfPeriod = if newPeriod then open else openOfPeriod[1];

#capture the low/lowest that occurs after highofperiod --this is where i need help
def lowAfterHigh = ?????

Thanks

Solution
Can anyone help with this study?

Plot Lowest Low that comes after the Intraday High?

Try This

Ruby:
``````#Highest High during RTH
def h        = compoundValue(1,
if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
then high
else max(high,h[1]), h[1]);

def hbn      = if GetDay() == GetLastDay()
then if high == h
then BarNumber()
else hbn[1]
else 0;

def hday     = if BarNumber() == HighestAll(hbn)
then high
else hday[1];

plot highday = hday;
highday.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#Lowest Low after High of Day
def l       = if...``````
What is the period in which you want to capture the lowest low?

same inPeriod

Try changing your definition of lowOfPeriod so that it gets reset if the highOfPeriod gets updated with a new high.

lowofperiod is different from the lowafterhigh as the low of the period can occur before highofperiod .
Trying to use barnumber , have to see if i get see sample codes on that

@daven I'm a little confused. On your original request you said " the Lowest low within a specified period after Highest High is captured in the specified period,". In your last post you said the low can happen before the high. If you want to capture the lowest low after a new highest high, then use:
Ruby:
``if newPeriod then low else if highofPeriod > highofPeriod[1] then low else if inPeriod then if low < lowOfPeriod[1] then low else lowOfPeriod[1] else lowOfPeriod[1]``

The added condition resets the low when a new high is made.

@daven I'm a little confused. On your original request you said " the Lowest low within a specified period after Highest High is captured in the specified period,". In your last post you said the low can happen before the high. If you want to capture the lowest low after a new highest high, then use:
Ruby:
``````if newPeriod then low else if highofPeriod > highofPeriod[1] then low else if inPeriod then if low < lowOfPeriod[1] then low else lowOfPeriod[1] else lowOfPer
The added condition resets the low when a new high is made.
[/QUOTE]
Thanks for looking into this and sorry for the confusion , the attached chart snippet will show what the instance I was trying to describe. I will test the new code snippet.. Thanks
[ATTACH=full]11493[/ATTACH]``````

Can anyone help with this study?

Plot Lowest Low that comes after the Intraday High?

Can anyone help with this study?

Plot Lowest Low that comes after the Intraday High?

Try This

Ruby:
``````#Highest High during RTH
def h        = compoundValue(1,
if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
then high
else max(high,h[1]), h[1]);

def hbn      = if GetDay() == GetLastDay()
then if high == h
then BarNumber()
else hbn[1]
else 0;

def hday     = if BarNumber() == HighestAll(hbn)
then high
else hday[1];

plot highday = hday;
highday.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#Lowest Low after High of Day
def l       = if BarNumber() == HighestAll(hbn + 1)
then low
else Min(low, l[1]);
def lbn     = if GetDay() == GetLastDay() and  secondsfromtime(1600)<0
then if low == l
then BarNumber()
else lbn[1]
else 0;
def lday    = if barnumber()==Highestall(lbn) then l else lday[1];
plot lowday = lday;
lowday.setpaintingStrategy(paintingStrategy.HORIZONTAL);``````

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
390 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
• 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?