Problem of colors in an indicator  [SOLVED]

Questions about MultiCharts and user contributed studies.
joel76
Posts: 3
Joined: 12 Sep 2012
Has thanked: 1 time

Problem of colors in an indicator

Postby joel76 » 30 Oct 2012

Hello
First I apologise for my poor English.
I'm newbie on Multicharts and I would like to test a very simple indicator, here is the code

Code: Select all

variable : Color(red) ;
Color = AB_Color_Chart(Close, Green, Red);

Plot1(Close , "close ", Color) ;
Plot2[1] (Close[1] , "my close", Color) ;
where AB_Color_Chart has this code

Code: Select all

// AB_Color_Char

inputs :
Tableau(NumericSeries), // values studie
ColorUp(numeric), // color when value >= value[1]
ColorDown(numeric); //color when value < value[1]

if Tableau >= Tableau[1] then
AB_Color_Chart = ColorUp
else
AB_Color_Chart = ColorDown;
I'd like a color green between the points when the value grows and red when it does'nt but the function does'nt work.
Color uses with plot2 works well (but plot2 does'nt print close[0]) and when I use Color with plot1, it does'nt.
How can I manage the colors for that it works for close ?

Thank you all

Joel

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Problem of colors in an indicator

Postby Henry MultiСharts » 30 Oct 2012

Hello Joel,

I have tested your code and it works as expected.
The function paints the plot according to the specified colors.
Plot2 is correct and it is overlapped by plot1 as you are referencing previous close value in plot2 and you offset it 1 bar forward.

Please explain in details what the problem is exactly and attach screenshots demonstrating the issue.

joel76
Posts: 3
Joined: 12 Sep 2012
Has thanked: 1 time

Re: Problem of colors in an indicator

Postby joel76 » 30 Oct 2012

You're right, with a picture it's easier :
Image
The code is

Code: Select all

variable : Color(red) ;
Color = AB_Color_Chart(Close, Green, Red);

Plot1(Close , "close ", Color) ;
// Plot2[1] (Close[1] , "my close", Color) ;
Look at AB_Bidon2. Only plot1 is printed. You can see that the line is red sometimes when the value grows, it should be green, and sometimes it's green when it should be red.
When plot2 is printed, it works well but doesn't go to close[0].
I would like only one plot that does all the line entirely (up to close[0]) with the good color.

Thank you

Joel

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Problem of colors in an indicator  [SOLVED]

Postby TJ » 30 Oct 2012

Hello
First I apologise for my poor English.
I'm newbie on Multicharts and I would like to test a very simple indicator, here is the code
...
Thank you all

Joel
Welcome to MultiCharts.
Please do not apologise for poor English; most people here do not use English as mother language. If needed, you can always post in your native language, we will use Google Translate to understand you.

For your code, try this:

Code: Select all

variable : Color(0) ;
Color = AB_Color_Chart(Close, Green, Red);

Plot1(Close , "close ", Color) ;
setplotcolor[1](1, Color) ;

joel76
Posts: 3
Joined: 12 Sep 2012
Has thanked: 1 time

Re: Problem of colors in an indicator

Postby joel76 » 30 Oct 2012

Thanks you very much. This is exactly what I was looking for.
I didn't think that [N] works for functions like setplotcolor.

Bye.


Return to “MultiCharts”