公式网-网站导航


网站搜索:  

公式指标网 发表于2019/3/7 7:52:17

n日内涨幅问题

编写要求:

 

www.gszx.com.cn网解答:

 网友求助:

求100日内涨幅最大的前50个交易日涨幅总和,这个公式怎么编写?
 
 
解答如下:
input:n(100,1,9999);
wx:=barslast(barpos=0);
nn:=wx;
if datacount<n then begin
nn:=datacount-1;
end else begin
nn:=n;
end;
ZF:=(c/ref(c,1)-1)*100;
dt:=datacount;
tmp:=sort(ZF,0, dt-nn+1,dt);
ZFv:=(c/ref(c,1)-1)*100;
sp:=c*0;
for i=dt downto dt-nn+1 do begin
for j=dt downto dt-nn+1 do begin
if ZFv[j]=ZF[i] then
sp[j]:=i;
end;
end;
ZFp:=if(sp-(dt-nn)>=50,ZFv,0);
涨幅总和:sum(ZFp,0);
 


网站搜索:  



Copyright © 2009-2010 gszb.com ™,All Rights Reserved. 
公式网-www.gszx.com.cn-股票指标公式网