[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] user-defined function error



PureBytes Links

Trading Reference Links

I want to write a stochastic indicator, during which I define an 
fuction SMA(input,n,m).  Could some one kindly advise why in the 
following code,  PLOT RSV1 is OK, but plot RSV2 is not ?

----------------------------------------------



RSV1= (Close-LLV(Low,35))/HHV(High,35);
RSV2= (Close-LLV(Low,35))/(HHV(High,35)-LLV(Low,35))*100;


function SMA(x,n,m)

{ 
    result[ 0 ] = x[ 0 ]; 
   

    for( i = 1; i < BarCount; i++ ) 
    { 
       result[ i ] = (x[i] *m +(n-m)* result[ i -1 ])/n; 
    } 

   return result; 
} 

Plot(sma(RSV1,10,1),"sma10 for rsv1",colorRed);// this plot is ok

Plot(sma(RSV2,10,1),"sma10 for rsv2",colorgreen);  // this plot is 
wrong




Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.13/546 - Release Date: 11/22/2006