Variable Period Indicator/Colouring

 

Hi Folks!

In my endless search for strange and odd things, I am never comfortable about periods and bars. So, I need help with the following code. The basic stuff is, if it completes a full single wave phase, where the compared waves are (high+low)/2 and (open+close)/2, the color of the indicator changes. In fact, any indicator.For me, only makes sense calculating inside one single phase, for any indicator. And every phase has an unpredictable number of bars, as umpredictable as the market is.

I've attached the code, but I'm not still sure on how any indicator would fit a variable number of bars. And as I am not able to code it, i drew it on paint (now you can lagh, :D WTF?!?).

There it goes. The vertical lines are for vieweing purposes only. Between them, one could (re)calculate and indicator for a new high, if it were a bar itself. I could draw candles though.


Files: