以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]一个tb模型的自适应均线的写法,求改成金字塔的  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=48980)

--  作者:人生如棋
--  发布时间:2013/2/27 13:36:44
--  [求助]一个tb模型的自适应均线的写法,求改成金字塔的

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

 请大虾帮忙改下。。。。

[此贴子已经被作者于2013-2-27 13:37:15编辑过]

--  作者:jinzhe
--  发布时间:2013/2/27 13:40:04
--  

直接贴这样的代码,要有人同时精通TB和金字塔,才能帮你改

你还是把每句话都给注释一下