Hi,

I'm having problems using the 2nd order smoother from the Library.

as long as i use O,H,L,C I can plot the IIR2.

However when I make a calculation and want to smooth the result, I get 'EMPTY' 
as a result.

If I use IIR2(C,0.2,1.4,-0.6); --> output
If I use [ a=(H+L+C)/3 ] IIR2(a,0.2,1.4,-0.6); --> output
If I use [ a=MA(c,20) ]  IIR2(a,0.2,1.4,-0.6); --> no output

The code says it uses the data array as input... Is that why i can not use it 
on a random array? And if so, how do i accomplish being able to use it on any 
array.

Here is the code as published in the Library.

// the following function is 2nd order smoother
// Input is the data array
// f0, f1, f2 are filter coefficients
// you can try 0.2, 1.4, -0.6 

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( Close, "Price", colorBlack, styleCandle );
Plot( IIR2( Close, 0.2, 1.4, -0.6 ), "function example", colorRed ); 

Thanks

Marc

Reply via email to