# How can i do that: Coloring the body of a bar

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1270
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

### How can i do that: Coloring the body of a bar

Hello

I would like to create an indicator that will color only the body of a candel bar, depending on some rules

A): Green if the close is higher than the preceiding close
B): Blue if the close is lower than the precieiding
C): Purple if the close equal the preceiding close

What I'm looking is the command to color a bar. I did look in EasyLanguage Functions and Reserved Words Reference, but did not found it.

Martin

TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

### Re: How can i do that: Coloring the body of a bar

arjfca wrote:Hello

I would like to create an indicator that will color only the body of a candel bar, depending on some rules

A): Green if the close is higher than the preceiding close
B): Blue if the close is lower than the precieiding
C): Purple if the close equal the preceiding close

What I'm looking is the command to color a bar. I did look in EasyLanguage Functions and Reserved Words Reference, but did not found it.

Martin

try this:

Code: Select all

var:
color(0);

if c > c[1] then color = green
else
if ....

plot10( high, "high" , color);
plot20( low, "low" , color);

in the Format Study window,
set plot10 to bar high
set plot20 to bar low

set the weight to the thickest line.

arjfca
Posts: 1270
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

### Re: How can i do that: Coloring the body of a bar

Hello TJ

I was to reply that I have solved my interogation. Here is my solution

The last number " 10" is the LineWidth. I have selected so it filled the body

Code: Select all

If close > close [1] Then PlotPaintBar(Open,Close,"",Green,default,10);
If close < close [1] Then PlotPaintBar(Open,Close,"",red,default,10);
If close = close [1] Then PlotPaintBar(Open,Close,"",Blue,default,10);

Martin
Attachments
ColorBar.jpg (79.5 KiB) Viewed 105 times

TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

### Re: How can i do that: Coloring the body of a bar

arjfca wrote:Hello TJ

I was to reply that I have solved my interogation. Here is my solution

The last number " 10" is the LineWidth. I have selected so it filled the body

Martin

Looking good !

One small suggestion -- if you put the "else" in the code, it will run slightly faster.
Also, you do not need the last "If close = close [1] Then..." because it is implied.

Code: Select all

If close > close [1] Then PlotPaintBar(Open,Close,"",Green,default,10)
else
If close < close [1] Then PlotPaintBar(Open,Close,"",red,default,10)
else
PlotPaintBar(Open,Close,"",Blue,default,10);

arjfca
Posts: 1270
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

### Re: How can i do that: Coloring the body of a bar

Nicely put. I will use your little modification in future codes improvement.
I ought you two and a half sandwichs now

Martin