Tone color when increase

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
NiC72
Posts: 92
Joined: 02 Nov 2009
Location: Sweden
Has thanked: 35 times
Been thanked: 12 times

Tone color when increase

Postby NiC72 » 08 Dec 2015

Is there any possibility to tone color (like GradientColor) of the plot when I zoom (Increase bar spacing) the chart-window ?

SP
Posts: 455
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Tone color when increase

Postby SP » 09 Dec 2015

You could try something like that:

Code: Select all

vars: barcolor ( 0 );


Switch(getappinfo(aibarspacing)) begin
case < 6: barcolor = red;
case < 8: barcolor = magenta;
case < 10: barcolor = yellow;
case < 15: barcolor = cyan;
case >= 15: barcolor = green;
end;

Plot1 ( 1 , "", barcolor ,barcolor );

NiC72
Posts: 92
Joined: 02 Nov 2009
Location: Sweden
Has thanked: 35 times
Been thanked: 12 times

Re: Tone color when increase

Postby NiC72 » 10 Dec 2015

SP , your solution was brilliant!
Tried to get the whole plot to change color , but without success.
The idea was to zoom in and when to see a more sensitive indicator ( hidden in the normal mode ).

SP
Posts: 455
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Tone color when increase

Postby SP » 11 Dec 2015

For changing the color in the past add a loop, i.e.:

Code: Select all




vars: intrabarpersist barcolor ( 0 );

Once barcolor = red;


Switch(getappinfo(aibarspacing)) begin
case < 6: barcolor = red;
case < 8: barcolor = magenta;
case < 10: barcolor = yellow;
case < 15: barcolor = cyan;
case >= 15: barcolor = green;
end;

Plot1 ( RSI (close,14) , "", barcolor ,barcolor );

for value1 = 1 to currentbar
begin
SetPlotColor [value1](1,barcolor);
end;


You only need to add some lines into your code to prevent that the color change is calculated at each tick.

NiC72
Posts: 92
Joined: 02 Nov 2009
Location: Sweden
Has thanked: 35 times
Been thanked: 12 times

Re: Tone color when increase

Postby NiC72 » 16 Dec 2015

Thanks SP, you are a star!
Everything works as I wanted.

Code: Select all

Vars: intrabarpersist barcolor(0);

Once barcolor = red;

{------------------ Switch Plot Color ------------------}
Switch(getappinfo(aibarspacing)) begin
case < 0.10: barcolor = white;
case < 0.40: barcolor = magenta;
case < 0.70: barcolor = yellow;
case < 1: barcolor = cyan;
case >= 1: barcolor = green;
end;
{---------------- End Switch Plot Color ---------------}

Plot1 (RSI(close,14),"testRSI",barcolor,barcolor);

{------------------ Set Plot Color --------------------}
if (barColor <> barColor[1]) then
begin
for value1 = 1 to currentbar
begin
SetPlotColor[value1](1,barcolor);
Print("SetPlotColor");
end;
end;
{----------------- End Set Plot Color -----------------}


Return to “User Contributed Studies and Indicator Library”