Adaptive lookback indicators

 

Of adaptive lookbackThe Adaptive Lookback (period finder) is truly a market-driven indicator used to determine the variable lookback period for many different indicators, instead of a traditional, fixed figure.

It is based on the frequency of market swings - the time between swing highs or swing lows. A swing high is defined as two consecutive higher highs followed by two consecutive lower highs; a swing low is defined by two consecutive lower lows followed by two consecutive higher lows. As swing points typically accompany reversals, they occur more frequently in choppier and volatile markets than in trends.

Adaptive lookback period is determined as :

  1. Determine the initial number of swing points (swingCountparameter) to use in the calculation.
  2. Count the number of price bars it takes for the n swing points to form.
  3. Divide step 2 by step 1 and round the result.

Interpretation

This makes the variable lookback period grow in calm or trending markets, and shorten in range-bound and volatile markets. For a trend-following system you would like the opposite to prevent being whipsawed, therefore this indicator and it's usage as a period modifier is more suitable for short-term traders and counter-trend systems (so, in all systems where maximal speed of reaction and signaling is required).

Experiment with applying the adaptive lookback period to different indicators and you'll see how more responsive they become in volatile markets. Some of the experiments are going to be posted on this thread with immediate comparison to "non-adaptive" counterparts

Attached on this post

alb - swing points -> the basic indicator (simply showing swing points). You will notice that it draws the "peak" with 2 bars displacement. That is done in order to avoid any any kind of repainting (no lag is added to swing points finding thought)

alb - periods -> the "next step" : periods already calculated

alb - RSI -> RSI made adaptive with a help of alb period finder

__________________________________

PS: the last sub-window is a compared 14 period RSI (green) and alb - RSI with swingCount set to 5 (red)

Files:
 

Adaptive lookback stochastic

Adaptive lookback stochastic

On the picture compared to "regular" (14,3,3) stochastic. It seems that it really does reacts much faster than the regular one (but I leave the exploration and conclusion of it to all of you)

 

Adaptive lookback moving average

Adaptive lookback moving average

Compared - 5 swingCount adaptive lookback moving average (ema mode) (green) and 14 period ema (red). Speed of change obviously can not be compared,and a "lessened lag" seems to make alb suitable for filtering

Files:
alb_-_ma.mq4  2 kb
alb_-_ma.gif  15 kb
 

Metatrader 5 versions ...

Adaptive lookback swing points - metatrader 5 version

Adaptive lookback periods - metatrader 5 version

 

...

And addition (modification) to the original adaptive lookback way of determining periods : the "original way" lacks a way to manage the "speed of change" (it always looks for fastest way to react on volatile market) and it makes it self-similar for any swing count value.

________________________________

These versions correct that inability of change : with the speedparameter one can modify the desired speed of change. It works in an obvious way : values for speedless than 1 are "slowing" the indicator down, values greater than 1 are "speeding" them up. As an example, on the picture are compared alb stochastic with 3 different "speeds" :
1. sub-window -> speed 1

2. sub-window -> speed 2

3. sub-window -> speed 0.5

 

Adaptive lookback RSI- metatrader 5 version

Adaptive lookback RSI- metatrader 5 version

Two versions : the "original" version and the "speed change" version. Compared on the picture :

RSI -> blue

"original" alb RSI -> lime

"speed change" RSI -> gold (speed 0.5 here - so slowed down alb)

Files:
 

Adaptive lookback stochastic - metatrader 5

Adaptive lookback stochastic - metatrader 5 version

__________________________________

On the picture compared to "regular" stochastic (upper indicator sub-window). Response time is better than the "regular" stochastic, but the recommendation is still the same : use for "fast change detection systems"

Parameters are the usual (difference compared to stochastic is only in the Swing count parameter : this one uses Swing count to determine stochastic period (as shown in alb - periods indicator) instead of using fixed length for calculation)

PS: added the "speed change" version here too (see next post for explanation)

 

Adaptive lookback ma - metarader 5 version

Adaptive lookback ma - metarader 5 version

Immediately made a "original" and the "speed change" version. Compared on the picture : alb ema swing count 5 original and alb ema (green) swing count 5 speed 0.5 ("slowed down" in this case - gold)

____________________________

PS: difference in values compared to metatrader 4, apart from difference in data comes from a fact that these versions do not use internal ma calculation and thus do not have a limitation that internal ma calculation has - the "forced integer period" limitation (here period is, except in LWMA a normal double and it, in case of EMA or SMMA can make a big difference - it is done to preserve precision and to avoid that trap of internal indicators)

 

Adaptive lookback

Mladen thanks for these alb indicators, check out this chart everything except Volume is using alb, anyway wondering if there is a way to use H4 or any higher timeframe alb the way Simba does in his TMA Cycle thread, on this chart using your alb with H1 TMA bands (white bands) with another adaptive band set for H4, would it be possible to do this using your alb code? Tried my old way but didn't work!

Thanks in advance.

Files:
adaptive_1.gif  83 kb
 

Alb

Made these after reading pdf posted about adaptive price zone by Mladen in elite indicators section, but instead of using Ema used TMAcentered High-Tmacentered low for adaptive zone and alb+speed+TMAcentered for adaptive lookback, using with adx > 40 and going down looks interesting!

 

...

mrtools:
Made these after reading pdf posted about adaptive price zone by Mladen in elite indicators section, but instead of using Ema used TMAcentered High-Tmacentered low for adaptive zone and alb+speed+TMAcentered for adaptive lookback, using with adx > 40 and going down looks interesting!

Nice work tools ____________________________

However it raised some questions in my head and here is a conclusion :

I was wondering why is the indicator slowing metatrader down (on time frame changes especially), since the code you wrote correctly, simply and clear. Until it hit me :
Problem comes from the way metatrader treats external indicators. It opens separate thread for every indicator with different parameters combination. So, when used in combination with adaptive look back it opens as much separate triangular ma indicators as there are different half length periods (see the picture attached - those are all opened by alb+speed+Tmacentered (even more on the top of the list )

So, in order to avoid it, made this one with internal calculations of the whole thing. Results are the same (value wise) but see the list of opened indicators. Yes, that is all (the one on the top of the list) It seems that we have to be careful with metatraders hunger for memory and processors

regards

mladen

Reason: