等级: 免费版
- 注册:
- 2023-11-16
- 曾用名:
|
input : lots(1,1,1000,1);//头寸
input : SLSS(1,1,1000,1);//加仓
input : hld(10,1,1000,1);//获利
input : zsd(30,1,1000,1);//止损
input : qdyd(30,1,1000,1);//移动保护启动点
input : yd(5,1,1000,1);//移动保护
variable:num=0; // 全局变量,来控制当天交易次数
cs:=1;
sss1:callstock(stklabel,vtclose,6,-1);
sss2:callstock(stklabel,vtopen,6,0);
tt:=if(holding<>0,openbar,3);
hhh:=ref(hhv(h,tt+1),1);
lll:=ref(llv(l,tt+1),1);
if sss1<sss2 then begin
sellshort(1,holding,limitr, open);
if num<cs then
begin
buy(holding=0,lots,limitr, open);
num:=num+1;
BUY(OPENPROFIT>20,SLSS,limitr, open);
end
end
if sss1>sss2 then begin
sell(1,holding,limitr, open);
if num<cs then
begin
buyshort(holding=0,lots,limitr, open);
BUYSHORT(OPENPROFIT>20,SLSS,limitr, open);
num:=num+1;
end
end
if holding >0 then begin//多单止盈
bccj:=max(avgenterprice+hld*mindiff,open);
sell(h>=avgenterprice+hld*mindiff,holding,limitr, bccj);
end
if holding >0 then begin//多单止损
bccj1:=min(avgenterprice-zsd*mindiff,open);
sell(l<=avgenterprice-zsd*mindiff,holding,limitr, bccj1);
end
if holding >0 and hhh>=avgenterprice+mindiff*qdyd and enterbars>0 then begin//多单止损
bccj2:=min(avgenterprice+yd*mindiff,open);
sell(l<=avgenterprice+yd*mindiff,holding,limitr, bccj2);
end
/////////////////
if holding <0 then begin//空单止盈
sccj:=min(avgenterprice-hld*mindiff,open);
sellshort(l<=avgenterprice-hld*mindiff,holding,limitr,sccj);
end
if holding <0 then begin//空单止损
sccj1:=max(avgenterprice+zsd*mindiff,open);
sellshort(h>=avgenterprice+zsd*mindiff,holding,limitr,sccj1);
end
if holding <0 and lll<=avgenterprice-mindiff*qdyd and enterbars>0 then begin//空单止损
sccj2:=max(avgenterprice-yd*mindiff,open);
sellshort(h>=avgenterprice-yd*mindiff,holding,limitr,sccj2);
end
if time>=185900 then
begin
sell(1,holding,market);
sellshort(1,holding,market);
end
if time=closetime(0) then num:=0;
当前持仓:holding,colorred,linethick0;
当前资产:asset,noaxis,colorgray;
盈亏比: payoffrate,colormagenta;
胜率:percentwin,coloryellow;
|
|