# net change from the opening bar with the current bar

#### LGLyon

##### New member
I need help with an indicator plotting the net change from the opening bar with the current bar. I forgot to change the title of this post.

Solution
I need help with an indicator plotting the net change from the opening bar with the current bar. I forgot to change the title of this post.

compare the open of the day with the current close

Code:
``````# day_open_chg_00

declare lower;

def na = Double.NaN;
def bn = BarNumber();
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def newday = (GetDay() != GetDay()[1]);

def dayopen = if bn == 1 then open
else if newday then open
else dayopen[1];

def daydiff = close - dayopen;

plot z = daydiff;
z.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
z.AssignValueColor(if daydiff > 0 then color.green
else if daydiff < 0 then color.red
else color.gray);
#``````

I need help with an indicator plotting the net change from the opening bar with the current bar. I forgot to change the title of this post.

compare the open of the day with the current close

Code:
``````# day_open_chg_00

declare lower;

def na = Double.NaN;
def bn = BarNumber();
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def newday = (GetDay() != GetDay()[1]);

def dayopen = if bn == 1 then open
else if newday then open
else dayopen[1];

def daydiff = close - dayopen;

plot z = daydiff;
z.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
z.AssignValueColor(if daydiff > 0 then color.green
else if daydiff < 0 then color.red
else color.gray);
#``````

compare the open of the day with the current close

Code:
``````# day_open_chg_00

declare lower;

def na = Double.NaN;
def bn = BarNumber();
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def newday = (GetDay() != GetDay()[1]);

def dayopen = if bn == 1 then open
else if newday then open
else dayopen[1];

def daydiff = close - dayopen;

plot z = daydiff;
z.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
z.AssignValueColor(if daydiff > 0 then color.green
else if daydiff < 0 then color.red
else color.gray);
#``````

Perfect. You do great work. thanks

Last edited by a moderator:

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