[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`Re: Coding help for color?



PureBytes Links

Trading Reference Links

 > I have been trying to plot a moving average where if it is going up it
 > is one color and if it is going down it's a different color. I've done
 > it a couple of different ways but not receiving the desired effect.
 > One of the ways is listed below but it lags one bar in color.  Can
 > someone please help with the correct method.

This is a Tradestation idiosyncracy. The color in the Plot statement 
applies to the "current bar". So if you're plotting points, the point 
shows in the correct color. But if you're plotting lines, it applies to 
lines drawn after the current point, so it doesn't affect the color of 
the line connecting the previous bar to the current bart. In effect, it 
delays showing the color by one bar, and delays the visual cue you want 
to see.

If you want to show the color of the line connecting the current bar to 
the previous bar, set the color of the previous bar using 
"plot1[1](...)". Be sure that the value you're plotting is the value on 
the previous bar.

/Greg


{ Show how to colorize lines }

{ Plot1 is a line }
{ plot2 is a point }
{ plot3 is a line }

value1 = average(h,10);

{ The point current bar shows in the desired color }
plot1(value1,"",iff(value1>value1[1],green,red),default,1);

{ But the line connecting the current bar to the previous }
{ bar is in the old color }
plot2(value1+1,"",iff(value1>value1[1],green,red),default,1);

{ Use two plot to force the connecting bar to be the }
{ current color }
plot3[1](value1[1]-1,"",iff(value1[1]>value1[2],green,red),default,1);
plot3(value1-1,"",iff(value1>value1[1],green,red),default,1);