周MACD KDJ RSI

来源:百度文库 编辑:神马文学网 时间:2024/04/29 07:58:49
周MACD

input:long(26,20,100),short(12,5,40),m(9,2,60);
wtj1:=datediff(ref(date,1),date)<>weekday-ref(weekday,1) or barpos=1;
wtj:=refx(wtj1,1) or weekday=5;  //周末标记
fc:=close;
start:=barpos-barssince(wtj);
diff:0*close;
dea:0*close;
tmp:=setlbound(diff,start[datacount]);
tmp:=setlbound(dea,start[datacount]);
d1:=fc[start[datacount]];d2:=d1;wdea:=0;
for i=start[datacount]+1 to datacount do begin
  if wtj then begin
    d1:=(2*fc+(short-1)*d1)/(short+1);
    d2:=(2*fc+(long-1)*d2)/(long+1);
    wdiff:=d1-d2;
    wdea:=(2*wdiff+(m-1)*wdea)/(m+1);
    diff:=wdiff;
    dea:=wdea;
  end else begin
    diff:=(2*fc+(short-1)*d1)/(short+1)-
             (2*fc+(long-1)*d2)/(long+1);
    dea:=(2*diff+(m-1)*wdea)/(m+1);
  end;
end;
macd:2*(diff-dea),colorstick;