[PEL] 复制代码
input:m(30,1,500,1);
input:ss(10,1,400,1);
cc11:ema(ema(c,m),m),linethick2;
开多平空条件:=cross(cc11,ref(cc11,1));//开多平空条件
开空平多条件:=cross(ref(cc11,1),cc11); //开空平多条件
//止盈
if openprofitper>=3 then
begin
多止盈:sell(1,holding,market);
空止盈:sellshort(1,holding,market);
end
//止损
if openprofitper<=-3 then
begin
多止损:sell(1,holding,market);
空止损:sellshort(1,holding,market);
end
maxasset:=hhv(asset,enterbars+1);//开仓以来最大市值
//连续4周期市值在最大市值回落1%以下
if enterbars>=3 and all(asset<=maxasset*0.99,4) then
begin
pd1:sell(1,holding,market);
pk1:sellshort(1,holding,market);
end
//浮亏占总资产的20%
if openprofit<0 and abs(openprofit)/asset>=0.2 then
begin
pd2:sell(1,holding,market);
pk2:sellshort(1,holding,market);
end
//交易执行
if 开多平空条件 then
begin
pk0:sellshort(1,holding,marketr);
buy(holding=0,1,marketr);
end
if 开空平多条件 then
begin
pd0:sell(1,holding,market);
buyshort(holding=0,1,market);
end
浮动盈亏幅度:openprofitper,nodraw;
持仓:holding;
持仓均价:avgenterprice,nodraw;