Quote from John Merchant:
Scoffing fools. This algorithm has the benefits that it starts working on the first bar of data, unlike a moving average, and functions as a high order trend line, analogous to a linear regression. An infinite impulse response filter estimator is a much easier way to do this, however. Two variables in addition to the data. Two statements in the main body of code. Some people do not appreciate complexity. Others appreciate it too much. Tsokakis' detractors are as Aristotelians before the revelations of Newton.
John,
IIR would not be that convenient .
In the att. gif I have plotted 4 representative lines for k=0.1 to 0.4 [it is hard to need more...]. The white line [k=0.1] seems to match the best-fit parabolic. The problem is that k=0.1 is not ideal in other trend sequences.
Except if create the best-fit IIR...
But, this is another [probably interesting] story.
PS1: The AFL code for the lower IIR lines is
function IIR2( input, f0, f1, f2 )
{
result[ 0 ] = input[ 0 ];result[ 1 ] = input[ 1 ];
for( i = 2; i < BarCount; i++ )
{
result[ i ] = f0 * input[ i ]+f1 * result[ i - 1 ]+ f2 * result[ i - 2 ];
}
return result;
}
Plot(C,"C",1,64);
C1=L;
for(K=0.1;K<0.5;K=K+0.1)
{
RED=IIR2( C1, 0.3, 1.2+K, -0.5-K);
Plot(IIf(DateNum()>=1040831,RED,Null),"\n["+K+"]",10*K+1,8);
}
and may produce a best-fit IIR2 for Lows [respectively Highs] for further study. I will take a look by the week-end, the sea is still warm in the Aegean.
PS2. ...Aristotelians before Newton...
Wow !!I wouldnt like to be in their [miserable] place !!
[BTW, Isaac Barrows, the teacher on Isaac Newton, was an Aristotelian too, but it was clever enough to give the proper hints to his young student...]