[PEL] 复制代码 ma20:ma(c,20);
ma40:ma(c,40);
金叉:=cross(ma20,ma40);
死叉:=cross(ma40,ma20);
H1:VALUEWHEN(金叉,H);
L1:VALUEWHEN(死叉,L);
buycon:H>H1 and ma20>ma40;
sellcon:l<l1 and ma20<ma40;
ss:=2;//手数
KC_H:=REF(H,ENTERBARS+2);//开仓K最高价
KC_L:=REF(L,ENTERBARS+2);//开仓K最低价
//最高价大于开仓K最高价平空
if h>ref(KC_H,1) and holding<0 then 空损:sellshort(1,holding,market);
if l<ref(KC_L,1) and holding>0 then 多损:sell(1,holding,market);
if buycon then
begin
sellshort(1,holding,market);
buy(holding=0,ss,market);
end
if sellcon then
begin
sell(1,holding,market);
buyshort(holding=0,ss,market);
end |