# of bars since last new high

 

I have this indi that counts the number of bars since the last new high/low of a moving maximum/minimum of the close price: it could be used as input for a window function (that dynamically adjusts the look-back period of other indicators); Take a look at it: it is based on the #HH_LL indicator: when the upper line did its last increase in value is where the counter starts; You can do the same for the lower line, but my first question is: how would you write it that instead of looking at the last increase, it looks at the first increase?

btw: the website renames the attachments: I'd named them #HH_LL, #BarsSinceLastNewHigh and #BarsSinceLastNewLow.

My second question would be: how do you write it that the lines in the #HH_LL are switched? So you have instead of a moving maximum above and a moving minimum below, you get a moving minimum above and a moving maximum below the close price graph?