以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  自行绘制盈亏曲线  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=12543)

--  作者:小布丁
--  发布时间:2012/6/21 12:31:46
--  自行绘制盈亏曲线

variable:cc=0;
variable:mrj=0;
variable:mcj=0;
variable:zc=0;
variable:fy=0;
buycond:= ref(ma(c,10)>ma(c,60),1);
sellcond:=ref(ma(c,10)<ma(c,60),1);
if barpos=1 then zc=0;
if cc>0 and sellcond then begin
 yk:=zc+(c-mrj)*10;
 cc:=0;
end
if cc<0 and buycond then begin
 yk:=zc+(mcj-c)*10;
 cc:=0;
end
if cc=0 and buycond then begin
 mrj:=c;
 cc:=1;
end
if cc=0 and sellcond then begin
 mcj:=c;
 cc:=-1;
end
if cc<=0 then mrj=0;
if cc>=0 then mcj=0;
if cc>0 then begin
 fy:=(c-mrj)*10;
 zc:=yk+fy;
end
if cc<0 then begin
 fy:=(mcj-c)*10;
 zc:=yk+fy;
end

如何解决代码中重复累加资金的问题?

 


--  作者:jinzhe
--  发布时间:2012/6/21 13:09:52
--  
注释一下公式吧,这样看着好难理解
--  作者:阿火
--  发布时间:2012/6/21 14:47:44
--  

variable:cc=0;
variable:mrj=0;
variable:mcj=0;
variable:zc=0;
variable:fy=0;
buycond: =ma(c,10)>ma(c,60);
sellcond:=ma(c,10)<ma(c,60);
if cc>0 and sellcond then begin
 zc:=zc+(c-mrj)*10;
 cc:=0;
end
if cc<0 and buycond then begin
 zc:=zc+(mcj-c)*10;
 cc:=0;
end
if cc=0 and buycond then begin
 mrj:=c;
 cc:=1;
end
if cc=0 and sellcond then begin
 mcj:=c;
 cc:=-1;
end
if cc>0 then begin
 fy:=(c-mrj)*10;
end
if cc<0 then begin
 fy:=(mcj-c)*10;
end

资产:zc+fy,noaxis;


--  作者:小布丁
--  发布时间:2012/6/22 11:39:17
--  
图片点击可在新窗口打开查看谢谢!