等级: 免费版
- 注册:
- 2022-11-17
- 曾用名:
|
楼主 |
发表于 2024-11-6 09:34
|
显示全部楼层
整个策略是有好多个周期的平仓条件的,我截取部分过来,老师帮我看看不开仓的问题在哪里,直接帮我改一下最好,谢谢
input:ss(1,1,100,1);
MA4:=MA(CLOSE,20);
MID:=MA(CLOSE,20);
UPPER:MID + 2*STD(CLOSE,20);
LOWER:MID - 2*STD(CLOSE,20);
MA4_H:=stkindi('','ma.ma4',0,5,0);
MA4_30m:=stkindi('','ma.ma4',0,4,0);
MA4_15m:=stkindi('','ma.ma4',0,3,0);
MA4_10m:=stkindi('','ma.ma4',0,18,0);
MA4_5m:=stkindi('','ma.ma4',0,2,0);
MA4_3m:=stkindi('','ma.ma4',0,17,0);
MA4_1m:=stkindi('','ma.ma4',0,1,0);
UPPER_H:=stkindi('','BOLL.UPPER',0,5,0);
LOWER_H:=stkindi('','BOLL.LOWER',0,5,0);
Long:=CLOSE>MA4_H and MA4_H>ref(MA4_H,1) AND close >UPPER_H;
Short:=CLOSE<MA4_H and MA4_H<ref(MA4_H,1) AND close<LOWER_H;
variable:n=0;
if n=0 then
begin
buy(Long AND HOLDING=0,SS,THISCLOSE); buyshort(Short AND HOLDING=0,SS,THISCLOSE);
n:=1;
END
if n=1 and TYPE(4) then
begin
buy(Long AND HOLDING=0,SS,THISCLOSE);
END
if n=1 and TYPE(2) then
BEGIN
buyshort(Short AND HOLDING=0,SS,THISCLOSE);
END
//多头平仓1
LongY:=MA4_H>CLOSE AND Holding>0;
if LongY then
begin
sell(SS,0,Limitr,c);
END
//多头平仓2
LongX:=AVGENTERPRICE<MA4_30m AND MA4_30m>CLOSE AND Holding>0;
if LongX then
begin
sell(SS,0,Limitr,c);
END
//空头平仓1
ShortY:=CLOSE>MA4_H AND Holding<0;
if ShortY then
begin
sell(SS,0,Limitr,c);
END
//空头平仓2
ShortX:=AVGENTERPRICE>MA4_30m AND CLOSE>MA4_30m AND Holding<0;
if ShortX then
begin
sell(SS,0,Limitr,c);
END |
|