I am trying to code the following custom indicator. What's in my mind is similar to a price channel, but instead of using HHV or LLV I want the 3rd higher high and 3rd lower low. So for example, today is a new high for a move, I start with todays low, then working backwards find the next lower low (#2), then find the next lower low (#3). Obviously, this is not necessarily just three days back or LLV (L,3). It could be several days back to find the 3rd lower low.
I then plot a horizontal line from this low to the right side of the chart. When the market closes below this 3rd low line, I then switch to calculating the 3rd higher high. Same way, start with today's high, then find the next higher high(#2), then find the next (#3). I then plot a horizontal line from this high to the right edge of the chart. When the market closes above this line, I reverse and start over.
The other conceptual problem I am having is how to get started. What would determine if the first line was a 3rd high or a 3rd Low? Once you get started, it's no problem, you just flip back and forth. It is easy to see on a chart but I can't make the transition to the code.
Thanks in advance for any and all input,
James