[MT4指标]请教各位老大,此段代码如何翻译成MT指标?
/*[[
Name := ama
Author := Copyright ?2004, MetaQuotes Software Corp.
Link := http://www.metaquotes.net/
Separate Window := No
First Color := Blue
First Draw Type := Line
First Symbol := 217
Use Second Data := No
Second Color := Red
Second Draw Type := Line
Second Symbol := 218
变量参数
n 10 ,p 2 ,Q 30, K 15
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 ;;;;;
AMA:DMA(C, Constant);;;;;
FFilter:=( K / 100 ) * Std( AMA - REF( AMA , 1 ) , N ) ;;;;;
XA:=IF( AMA<REF( AMA , 1 ) , AMA , 0 ) ;;;;;
XN:=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) ;;;;;
PartLine(TT= -1,AMA) ;;;;;
PartLine(TT= 0,AMA) ;;;;;
]]*/
Variable : shift(0);;
defines: n(10),p(2),Q(30),K(15);;
Variable: direction(0),xx(0),volatility(0),er(0),fastc(0),slowc(0),ssc(0),constant(0);;
Variable: ama(0),ffilter(0),xa(0),XN(0),amalow(0),ya(0),yn(0),amahigh(0),rr(0),tt(0);;
SetLoopCount(0);;
// loop from first bar to current bar (with shift=0)
For shift=Bars-1 Downto 0 Begin
direction=Close-close[shift-N]
xx=abs(close-close[shift-1])
for n downto 1 Begin
volatility=volatility+volatility[shift-n]????
end; 这段不知道对不对,[em18] [em18]
er=abs(direction/volatility)
fastc=2/(p+1)
slowc=2/(q+1)
ssc=er*(fastc-slowc)+slowc;;
constant=ssc*ssc
ama=....
.........这里再如何向下写???
SetIndexValue(shift, 0);;;;;
End;;;;;
[em15] [em15] [em15] [em57] [em57] [em57] [em57]
[此帖子已被 dqj8848 在 2004-10-21 6:34:15 编辑过]