Indicators displays red instead of green when going upward

Questions about MultiCharts and user contributed studies.
duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Indicators displays red instead of green when going upward

Postby duration » 26 Mar 2010

Dear All,

This is what I have written:

Code: Select all


if indicator > indicator[1] then plot1(indicator,"indicator",green,default,2);
if indicator < indicator[1] then plot1(indicator,"indicator",red,default,2);
If you look at the screenshot, it is red although the indicator is going up.

Is there anything wrong with what I have written?

Many thanks.[/code][/quote]
Attachments
upred.png
(1.76 KiB) Downloaded 360 times

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 26 Mar 2010

Line style plots require that you use SetPlotColor[1](1, ColorHere) to set the color as of one bar ago. Histogram style plots do not require this.

What is happening is basically that you're changing the color, but it's taking effect 1 bar late because line style plots look at what the color was at the LEFT handle of the line segment connecting the two bar values to see what the color should be for that segment, and the color change you're making on a given bar is taking effect on the next bar. The SetPlotColor[1] allows you to change the color retroactively for the previous bar, so that the color change is instantaneous, and if the plot style is line, this is the right approach.

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Postby duration » 26 Mar 2010

Dear Bruce,

Thank you very much for your amazing reply, it fixed everything!

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 26 Mar 2010

You are welcome - good luck to you!


Return to “MultiCharts”