runmode:0;
variable:currentholding=0;
holding1:=stkindi(stklabel,'f1a.持仓',0,dataperiod,0);
holding2:=stkindi(stklabel,'f2a.持仓',0,dataperiod,0);
targetholding:=holding1+holding2;
if targetholding=0 then begin
if currentholding>0 then
sell(1,currentholding,limitr,close);
if currentholding<0 then
sellshort(1,-currentholding,limitr,close);
end
if targetholding>0 then begin
if currentholding=0 then
buy(1,targetholding,limitr,close);
if currentholding>0 then begin
if targetholding>currentholding then
buy(1,targetholding-currentholding,limitr,close);
if targetholding<currentholding then
sell(1,currentholding-targetholding,limitr,close);
end
if currentholding<0 then begin
sellshort(1,-currentholding,limitr,close);
buy(1,targetholding,limitr,close);
end
end
if targetholding<0 then begin
if currentholding=0 then
buyshort(1,-targetholding,limitr,close);
if currentholding>0 then begin
sell(1,currentholding,limitr,close);
buyshort(1,-targetholding,limitr,close);
end
if currentholding<0 then begin
if targetholding>currentholding then
sellshort(1,targetholding-currentholding,limitr,close);
if targetholding<currentholding then
buyshort(1,currentholding-targetholding,limitr,close);
end
end
currentholding:=targetholding;
仓位:holding,noaxis,linethick0;
收益:asset-500000,noaxis,colormagenta,linethick2;