# Need a bit of help

#### Dean

##### New member
I am trying to create an indicator, but the code I am working with I cannot get to work. I want to create a moving midpoint line of the high and low for the first 2 hours of a 5m chart. This is what I have so far:

Ruby:
``((Highest High of intraday) + (Lowest Low of Intraday)/2)``
It would be a moving average of the first 2 hours of a 5m chart from 8:30 cst to 10:30 cst. Thanks for the help, I s-ck at this.

Last edited by a moderator:
Solution
I am trying to create an indicator, but the code I am working with I cannot get to work. I want to create a moving midpoint line of the high and low for the first 2 hours of a 5m chart. This is what I have so far:

Ruby:
``((Highest High of intraday) + (Lowest Low of Intraday)/2)``
It would be a moving average of the first 2 hours of a 5m chart from 8:30 cst to 10:30 cst. Thanks for the help, I s-ck at this.

The midpoint moves within the timeframe input at which point it will stop plotting unless you want to extend it at the input. If you choose to extend it, the value of the midpoint at the end of 2 hours will plot to the end of regular trading hours (1600).

You have options to just show only the last day and whether to show...

#### SleepyZ

##### Well-known member
VIP
I am trying to create an indicator, but the code I am working with I cannot get to work. I want to create a moving midpoint line of the high and low for the first 2 hours of a 5m chart. This is what I have so far:

Ruby:
``((Highest High of intraday) + (Lowest Low of Intraday)/2)``
It would be a moving average of the first 2 hours of a 5m chart from 8:30 cst to 10:30 cst. Thanks for the help, I s-ck at this.

The midpoint moves within the timeframe input at which point it will stop plotting unless you want to extend it at the input. If you choose to extend it, the value of the midpoint at the end of 2 hours will plot to the end of regular trading hours (1600).

You have options to just show only the last day and whether to show the plots of the high and low lines.

The image below has extended lines selected.

Ruby:
``````input ShowTodayOnly = yes;
input ORBegin       = 0930;
input OREnd         = 1130;
input extended      = yes;
input showhigh_low  = yes;

def ORActive = if SecondsTillTime(OREnd) > 0 and
SecondsFromTime(ORBegin) >= 0
then 1
else if SecondsFromTime(ORBegin)[1] < 0 and
SecondsFromTime(ORBegin) >= 0
then 1
else 0;

def 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];

def 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];

def ORHexp = if IsNaN(close)
then ORHexp[1]
else ORHigh;

def ORLexp = if IsNaN(close)
then ORLexp[1]
else ORLow;

plot ORH = if (ShowTodayOnly and
GetDay() != GetLastDay())
then Double.NaN
else if extended and SecondsFromTime(0930) > 0 and SecondsTillTime(1600) > 0
then ORHexp[1]
else if !extended and ORActive
then ORHigh
else Double.NaN;

plot ORL = if (ShowTodayOnly and
GetDay() != GetLastDay())
then Double.NaN
else if extended and SecondsFromTime(0930) > 0 and SecondsTillTime(1600) > 0
then ORLexp[1]
else if !extended and ORActive
then ORLow
else Double.NaN;

plot MID = if (ShowTodayOnly and
GetDay() != GetLastDay())
then Double.NaN
else (ORH + ORL) / 2;

ORH.SetDefaultColor(Color.GREEN);
ORH.SetPaintingStrategy(PaintingStrategy.LINE);
ORH.SetLineWeight(2);
ORH.sethiding(!showhigh_low);
ORL.sethiding(!showhigh_low);
ORL.SetDefaultColor(Color.RED);
ORL.SetPaintingStrategy(PaintingStrategy.LINE);
ORL.SetLineWeight(2);
MID.SetDefaultColor(Color.LIGHT_ORANGE);
MID.SetPaintingStrategy(PaintingStrategy.LINE);
MID.SetLineWeight(2);``````

## 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?