-- 作者:hxbhz
-- 发布时间:2010/6/7 22:23:36
-- 请老师帮忙纠正一下这个公式的错误
这个是自适应移动平均线,在飞狐中能正确使用,但在金字塔里出错了,请老师帮忙修改一下,谢谢!
input:N(10,1,60); input:P(2,1,60); input:q(30,1,60); input:K(15,0,100);
Direction:=CLOSE - REF( CLOSE , N ) ; XX:=ABS( CLOSE - REF( CLOSE , 1 ) ) ; Volatility:=SUM( XX , N ) ; ER:=ABS( Direction / Volatility ) ; FastC:= 2 / ( p + 1 ) ; SlowC:= 2 / ( q + 1 ) ; SSC:=ER * ( FastC - SlowC ) + SlowC ; Constant :=SSC * SSC , Linethick0; YY:=REF( Close , 1 ) + Constant * ( CLOSE - REF( Close , 1 ) ) ; AA:=IF( SUM( 1 , 0 )= N + 1 , YY , 0 ) ; BB:=BarsLast( AA>0 ) ; DD:=REF( C , BB ) ; CC:=CLOSE , Linethick0 ; <%
NN= FFL.VarData("N")
VD= FFL.VarData("DD")
VC= FFL.VarData("CC")
Vonstant= FFL.VarData("Constant")
LT = UBound( VC )
for m=NN + 1 to LT
VD( m )=VD( m - 1 ) + Vonstant( m ) * ( VC( m ) - VD( m - 1 ) )
next
FFL.VarData("DD")=VD
%> AMA:DD , Linethick0; FFilter:=( K / 100 ) * Std( AMA - REF( AMA , 1 ) , N ) ; XA:=IF( AMAXN:=BarsLast( XA>0 ) ; AMALow :=REF( AMA , XN ) ; YA:=IF( AMA>REF( AMA , 1 ) , AMA , 0 ) ; YN:=BarsLast( YA>0 ) ; AMAHigh :=REF( AMA , YN ) ; RR:=IF( AMAHigh - AMA > FFilter , -1 , 0 ) ; TT:=IF( AMA - AMALow > FFilter , 1 , RR ) ; PartLine(TT=1,AMA) , ColorRed , Linethick2; PartLine(TT= -1,AMA) , ColorGreen , Linethick2; PartLine(TT= 0,AMA) , ColorWhite , Linethick2;
[此贴子已经被作者于2010-6-7 22:26:30编辑过]
|