Page 1 of 1

Decay-Based Recentering Indicators

Posted: Fri Jul 25, 2025 10:39 pm
by ionone
So I came up with this idea, because I had enough to see all those indicators based on Moving Averages, that are laggy as heck.

This technique allows recentering of any indicator to another curve (or in this instance price action)

the idea is to shift slightly the MA when price goes above or under it.

so we create a variable. I calle mine "vshift" (short for Vertical Shift)
this is the variable that we will nudge up and down slightly at each bar

I made such indicator in the past that was my first it's called Better Donchian Channels. you can check it here. It used a slightly different approach though but achieving the same result : an indicator closer to the price.

but how much to nudge the variable vshift ?

in this first indicator I use a fraction of the difference between the price and the MA.
So that if the price is far from the MA, the nudge has to be higher.

I also added two "decays" one bigger than the other, because we have two different situations : when the price is above or under the top and bottom channels (that correspond to the biggest decay) or when it's above or under the mid line (smaller decay)

the result ? a moving average that is much closer to the price action,even if it means losing a bit of smoothness.

here is the difference between two BB with same settings
So the main algo (in pseudo code) is :

Code: Select all

var : 
	decay = 0.01
	vshift = 0
	
at each new bar :
1) compute the last bar "MA" value :
ma1 = iMA(1)
ma1 = ma1 + vshift;

2) then update vshift according to the latest data
decay1 = fabs(c1-ma1)*decay;
         
if (close1 < ma1)
    vshift = vshift - decay1;
else if (close1 > ma1)
    vshift = vshift + decay1;
3) finally compute and display the final MA value
ma1 = iMA(1) + vshift
that's pretty straightforward, but it works well to "glue" a curve to another one

Re: Decay-Based Recentering Indicators

Posted: Sat Jul 26, 2025 7:28 pm
by ionone
I repost the indicator that started it all

the technique to recenter the channel is different from what I posted in pseudo algo in my first post

but in the end it does the same thing : making the channel more centered around price action

Normal Donchian Recentered Donchian