Variable Period Length Moving Average

 

If, on a chart, we have made two bars that are lower than at least the two bars prior and we trade a line back to a bar from that current bar that is at least as low as the current bar, there will be a highest bar between these two bars. The moving average that I would like is of period length from the high bar to the current bar bar length, inclusive. So if there are 5 bars from that high bar in between the two "connected" bars, inclusive, the period length of the MA of interest would be 5. If another lower bar was generated and the high bar between that one and bar before that was of equally low price was the same bar, then the period length of the MA of interest would then be 6.

Is there an Indicator/EA that produces this MA or could such be coded? Perhaps even something similar out there would be a good place to start.

 
yes it can be done. but you need a method how to identify the lows and highs. most likely the indicator will repaint the last swing. if you look at my side you will find an indicator which does nearly the same
 

How do I get to your side? Matched highs and low: If the current bar is lower than the prior two bars, draw a line back from the current bar to a bar that is at least as low. Then find the bar in between the current bar and that historic bar that was at least as low that is higher than all the other bars in between. That is the anchor bar. The number of bars from that high bar to the current bar is the period length of the MA. If the next bar after the current bar is higher, the MA period length stays the same. If it is lower, than you have to repeat all of the above for the new bar.

 
In that case the indicator you request would repaint the last 3 bars. Ps, i have send you a pm since posing a link is considered as adverticing here.
 

Hallo,

I am not sure if i understood your high/low method.

Current implementation:

If current bar is higher then the previous two a upswing has started

If current bar is lower then the previous two a downswing has started

Ma period is adjusted to the lengt of the swing.

I cannot see a system in this indicator :(