[PEL] 复制代码 cond1:=min(open,close)>ma(close,20);
cond2:=max(open,close)<ma(close,20);
cond3:=max(open,close)<ma(close,60);
ma60:ma(c,60);
MID:MA(CLOSE,20);//布林中轨
UPPER: MID + 2*STD(CLOSE,20);//布林上轨
LOWER: MID - 2*STD(CLOSE,20);//布林下轨
VARIABLE:mark1:=1,mark2:=1;
if ref(cond1 and o<c ,1) and open>MID and mark2 THEN
BEGIN
buy(1,25%,limitr,o),PERTRADER;
mark1:=1;//开仓后运行再次减仓
mark2:=0;
END
if ref(cond3 and o>c,1) and close<MID and holding>=0 THEN
BEGIN
全平:sell(1,0,market);
mark1:=1;
mark2:=1;
END
if ref(cond2 and o>c,1) and open<MID and holding>=0 and mark1 THEN
BEGIN
减仓:sell(1,50%,market),PERTRADER;
mark1:=0;
mark2:=1;
END
不能用holding限制 那就只能用全局变量。 设置成减仓或者加仓后才运行二次加仓或者开仓。 |