# Plot the low price of the 1-hour bar 9:00-10:00 a.m

#### shakib3585

##### Active member
VIP
Hello,

I am trying to plot the low price of the 1-hour trading bar starting at 9:00 a.m. and ending at 10:00 a.m. I have tried with the attached code, but it seems I am not getting the right data. Please correct my code.

Thanks
Code:
``````input startTime = 0900;
input endTime = 1000;
def timeUntilClose = SecondsTillTime(endTime);
def timeUntilOpen = SecondsTillTime(startTime);
def targetPeriod = timeUntilClose > 0;
rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low(period = aggregationPeriod.hour) else if targetPeriod and low(period = aggregationPeriod.hour) < targetPeriodLow[1] and low(period = aggregationPeriod.hour) > 0 then low(period = aggregationPeriod.hour) else targetPeriodLow[1];

plot a = targetPeriodLow;``````

Solution
Hello,

I am trying to plot the low price of the 1-hour trading bar starting at 9:00 a.m. and ending at 10:00 a.m. I have tried with the attached code, but it seems I am not getting the right data. Please correct my code.

Thanks
Code:
``````input startTime = 0900;
input endTime = 1000;
def timeUntilClose = SecondsTillTime(endTime);
def timeUntilOpen = SecondsTillTime(startTime);
def targetPeriod = timeUntilClose > 0;
rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low(period = aggregationPeriod.hour) else if targetPeriod and low(period = aggregationPeriod.hour) < targetPeriodLow[1] and low(period = aggregationPeriod.hour) > 0 then low(period = aggregationPeriod.hour) else targetPeriodLow[1];

plot a = targetPeriodLow;``````
...
Hello,

I am trying to plot the low price of the 1-hour trading bar starting at 9:00 a.m. and ending at 10:00 a.m. I have tried with the attached code, but it seems I am not getting the right data. Please correct my code.

Thanks
Code:
``````input startTime = 0900;
input endTime = 1000;
def timeUntilClose = SecondsTillTime(endTime);
def timeUntilOpen = SecondsTillTime(startTime);
def targetPeriod = timeUntilClose > 0;
rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low(period = aggregationPeriod.hour) else if targetPeriod and low(period = aggregationPeriod.hour) < targetPeriodLow[1] and low(period = aggregationPeriod.hour) > 0 then low(period = aggregationPeriod.hour) else targetPeriodLow[1];

plot a = targetPeriodLow;``````

Try this modification to your script

Code:
``````#Plot the low price of the 1-hour bar 9:00-10:00 a.m
input startTime = 0900;
input endTime   = 1000;

def targetPeriod    = secondsfromtime(starttime)>=0 and secondsTillTime(endtime) > 0;
def targetPeriodLow = if targetPeriod and !targetPeriod[1] then low(period = aggregationPeriod.hour) else if targetPeriod and low(period = aggregationPeriod.hour) < targetPeriodLow[1]  then low(period = aggregationPeriod.hour) else targetPeriodLow[1];

plot a = targetPeriodLow;
a.setpaintingStrategy(paintingStrategy.HORIZONTAL);``````

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