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
如何解决代码中重复累加资金的问题?
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;