Different Colors for Auto TrendLine Indicator

 

Happy Holidays everyone!

I use the "Auto TL 04" indicator to plot trend lines on my chart and it works very well for me. The only thing I can think of that would make it better is if it would display different colored trend lines instead of them all being a single color. I've tried a number of different ways to do this and have been able to get some of them to change colors but, not all of them (I end up with 1 a different color and all the others the same color) or the way I want (one try gave me a color that was not even called for, I don't know why). Could anybody out there show me a way to do this? I would be eternally thankful.

Attached is the indicator in question. The different colors don't need to be variables, they can be hard coded into the indicator.

Thanks for any help I get.

Files:
 

Maybe post some of the code that didn't work, and seek help with that. Otherwise, it might seem to some of our more cynical contributors that you are seeking someone to actually do the work for you, rather than just help you in your quest.

One approach might be to create an array of colours, and cycle round them at whatever point you wish, using a static/global index that you increment, and wrap around when it reaches the end of the list.

Something like

// code just typed, not compiled or checked or tested
   if(conditionToChangeColour)
      colourIx += 1;
   if(colourIx >= ArraySize(arrayOfColours))
      colourIx = 0;
Color useThisColour = arrayOfColours[colourIx];
 
// code just typed, not compiled or checked or tested
   if(conditionToChangeColour) colourIx = (colourIX+1) % ArraySize(arrayOfColours);
Color useThisColour = arrayOfColours[colourIx];