I've done a bit of work editing a stoch indicator to colour the line based on slope but have noticed that it leaves artifacts as the line changes slope during candle formation.

I have attached a screen shot of what the problem looks like. if you refresh the chart it goes away.. is there a way to make it clean up old plots during the candle formation? It's only a problem if it changes colour, plotting different slopes of the same colour is fine.

here's the code in question.

any assistance or pointing in the right direction would be much appreciated.

if (CurrentBar < 1) return; // Plot green if the %K is rising // Rising() returns true when the current value is greater than the value of the previous bar. if (Rising(Stochastics(PeriodD, PeriodK, Smooth).K)) { // Connects the rising plot segment with the other plots RisingPlot.Set(1, Stochastics(PeriodD, PeriodK, Smooth).K[1]); // Adds the new rising plot line segment to the line RisingPlot.Set(Stochastics(PeriodD, PeriodK, Smooth).K[0]); } // Plot red if the %K is falling // Falling() returns true when the current value is less than the value of the previous bar. else if (Falling(Stochastics(PeriodD, PeriodK, Smooth).K)) { // Connects the new falling plot segment with the rest of the line FallingPlot.Set(1, Stochastics(PeriodD, PeriodK, Smooth).K[1]); // Adds the new falling plot line segment to the line FallingPlot.Set(Stochastics(PeriodD, PeriodK, Smooth).K[0]); } // Plot yellow if the %K is neutral else { // Connects the neutral plot segment with the rest of the line NeutralPlot.Set(1, Stochastics(PeriodD, PeriodK, Smooth).K[1]); // Adds the new neutral plot line segment to the line NeutralPlot.Set(Stochastics(PeriodD, PeriodK, Smooth).K[0]); }

## Comment