[PEL] 复制代码 VARIABLE:zs:=0;//全局变量记录止损价
ma100:ma(c,100);
//macd指标模块
input:p(26,20,100,8),s(12,5,40,4),m(9,2,60,6);
diff :ema(close,s) - ema(close,p);
dea :ema(diff,m);
macd1 :=2*(diff-dea), colorstick;
kd:c>ma100 and macd1>ref(macd1,1) and all(macd1<0,2);
kk:c<ma100 and macd1<ref(macd1,1) and all(macd1>0,2);
L1:=REF(llv(l,5),1);
H1:=REF(hhv(h,5),1);
if kd and holding=0 then
begin
buy(1,1,market);
zs:=L1;
end
if kk and holding=0 then
begin
buyshort(1,1,market);
zs:=H1;
end
if c<zs and holding>0 then 多止损:sell(1,holding,market);
if c>zs and holding<0 then 空止损:sellshort(1,holding,market);
//年底 最后一根K 清仓
if MONTH=12 and ISMONTHEND and time=CLOSETIME(0) then
begin
sell(1,holding,market);
end |