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

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1260
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

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

Postby arjfca » 07 Apr 2011

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

User avatar
TJ
Posts: 6518
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

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

Postby TJ » 07 Apr 2011

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: 1260
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

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

Postby arjfca » 07 Apr 2011

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
ColorBar.jpg (79.5 KiB) Viewed 97 times

User avatar
TJ
Posts: 6518
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

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

Postby TJ » 07 Apr 2011

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: 1260
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

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

Postby arjfca » 07 Apr 2011

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

Martin


Return to “MultiCharts”