等级: 免费版
- 注册:
- 2022-7-28
- 曾用名:
|
//开仓语句
VARIABLE:N1 :=5;//亏损次数
VARIABLE:LOSSCOUNT:= 0;
VARIABLE:myks:= 0;
// 遍历每个 K 线周期判断
ph1:EMA(c,5);
ph2:EMA(c,20);
LONG:CROSS(PH1,ph2);
SHORT :CROSS(PH2,ph1);
if CROSS(ph2,ph1) THEN BEGIN
LOSSCOUNT:= 0;
END;
IF (CLOSE < ENTERPRICE and HOLDING=1) THEN BEGIN
LOSSCOUNT:=LOSSCOUNT + 1;
END
IF CROSS(ph1,ph2) THEN BEGIN
LOSSCOUNT:= 0;
END;
IF (CLOSE > ENTERPRICE and HOLDING>0) THEN BEGIN
LOSSCOUNT := LOSSCOUNT + 1;
END
// 判断连续亏损次数是否达到 5 次且均线下穿条件
IF LOSSCOUNT >= N1 THEN BEGIN//达到此条件再开仓
myks:=1;
END
IF LOSSCOUNT < N1 THEN BEGIN
myks:=0;//没有亏损
END;
IF HOLDING=0 AND LONG and myks=0 THEN BEGIN //ANDENTERTIME
BUY(1,1,LIMITR,C);
END
IF HOLDING=0 AND SHORT and myks=0 THEN BEGIN//AND ENTERTIME
BUYSHORT(1,1,LIMITR,C);
END
IF HOLDING>0 AND (REF(c,1)-C>MINDIFF*50) THEN SELL(1,1,LIMITR,c);//OR EXITTIME
IF HOLDING<0 AND (C-REF(c,1)>MINDIFF*50) THEN SELLSHORT(1,1,LIMITR,c);//OR EXITTIME
持仓:holding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0;
|
|