卡夫曼自適應移動平均TB源代碼(2011-10-17 10:06:51)
//------------------------------------------------------------------------ // 簡稱: AdaptiveMovAvg // 名稱: 求卡夫曼自適應移動平均 // 類別: 用戶函數(shù) // 類型: 內(nèi)建函數(shù) // 輸出: 數(shù)值型 //------------------------------------------------------------------------
Params NumericSeries Price(1); Numeric EffRatioLength(10); Numeric FastAvgLength(2); Numeric SlowAvgLength(30); Vars Numeric NetChg(0); Numeric TotChg(0); Numeric EffRatio(0); Numeric ScaledSFSqr(0); NumericSeries AMAValue; Numeric SFDiff; Begin if(CurrentBar == 0) { AMAValue = Price; }Else { NetChg = Abs( Price - Price[EffRatioLength] ); TotChg = Summation( Abs( Price - Price[1] ), EffRatioLength ); EffRatio = IIF(TotChg > 0, NetChg / TotChg, 0); SFDiff = 2 / ( FastAvgLength + 1 ) - 2 / ( SlowAvgLength + 1 ); ScaledSFSqr = Sqr( 2 / ( SlowAvgLength + 1 ) + EffRatio * SFDiff ); AMAValue = AMAValue[1] + ScaledSFSqr * ( Price - AMAValue[1] ); } Return AMAValue; End
//------------------------------------------------------------------------ // 編譯版本 GS2010.12.08 // 版權所有 TradeBlazer Software 2003-2010 // 更改聲明 TradeBlazer Software保留對TradeBlazer平 // 臺每一版本的TradeBlazer公式修改和重寫的權利 //------------------------------------------------------------------------
|