[MT4指标]帮忙把这个指标改成 MT4的
俺编程只有半桶水,MT3是用原有公式修改的,但现在MT4没有适合的可以改。
那位好心人帮帮俺。
Inputs : TIME_Period(10), MA_Period(4), SignalMAPeriod(4);
Variables : shift(0), loopbegin1(0), loopbegin2(0),loopbegin3(0), loopbegin4(0), first(True), prevbars(0), cnt(0), sum(0);
Variables : FastMA(0), SlowMA(0);
SetLoopCount(0);
If Bars < prevbars Or Bars-prevbars>1 Then first = True;
prevbars = Bars;
// loopbegin1 and loopbegin2 prevent couning of counted bars exclude current
If first Then Begin
loopbegin1 = Bars-MA_Period-1;
If loopbegin1 < 0 Then Exit; // not enough bars for counting
loopbegin2 = Bars-MA_Period-SignalMAPeriod-2;
If loopbegin2 < 0 Then Exit; // not enough bars for counting
loopbegin3 = Bars-MA_Period-SignalMAPeriod-3;
If loopbegin3 < 0 Then Exit; // not enough bars for counting
loopbegin4 = Bars-MA_Period-SignalMAPeriod-4;
If loopbegin4 < 0 Then Exit; // not enough bars for counting
first = False; // this block is to be evaluated once only
End;
// convergence-divergence
loopbegin1 = loopbegin1+1; // current bar is to be recounted too
For shift = loopbegin1 Downto 0 Begin
FastMA = iADX(TIME_Period,MODE_MINUSDI,shift);
SetIndexValue(shift,FastMA);
loopbegin1 = loopbegin1-1; // prevent to previous bars recounting
End;
// signal line
loopbegin2 = loopbegin2+1; // current bar is to be recounted too
For shift = loopbegin2 Downto 0 Begin
sum = 0;
for cnt = 0 To MA_Period-1 Begin
sum = sum + GetIndexValue(shift+cnt);
End;
SetIndexValue(shift,sum/MA_Period);
loopbegin2 = loopbegin2-1; // prevent to previous bars recounting
End;
loopbegin3 = loopbegin3+1; // current bar is to be recounted too
For shift = loopbegin3 Downto 0 Begin
SlowMA = iADX(TIME_Period,MODE_PLUSDI,shift);
SetIndexValue2(shift,SlowMA);
loopbegin3 = loopbegin3-1; // prevent to previous bars recounting
End;
// signal line
loopbegin4 = loopbegin4+1; // current bar is to be recounted too
For shift = loopbegin4 Downto 0 Begin
sum = 0;
for cnt = 0 To SignalMAPeriod-1 Begin
sum = sum + GetIndexValue2(shift+cnt);
End;
SetIndexValue2(shift,sum/SignalMAPeriod);
loopbegin4 = loopbegin4-1;
End;
在主版晾了很久,没回应。也在这里晾一下。:L
发表于:2006-05-18 10:27只看该作者
2楼
ddddddddddddddddddd
韬客社区www.talkfx.co
3楼
谢谢FCZ的支持!
韬客社区www.talkfx.co