如何设置holding [金字塔]
- 咨询内容:
下面是我做的改变,发现部分信号消失了,该表达的没有表达出来,如何用holding才能让我的开平连贯 不缺失 不漏少 信号 ,开仓前要清仓 。下面的源码为一个模型(上半部分)加了一个顶底指标(下半部分),所以尽量满足,开多仓后,顶底指标若还是开多就不开仓,若顶底指标或原模型出平仓,则平掉。不加仓吧
要求:解决,我修改后,部分信号不出现问题。
原代码为:
HA:=stkindi('','YY.ss',0,5);
HB:=stkindi('','YY.60up',0,5);
HC:=stkindi('','YY.60down',0,5);
HD:=stkindi('','YY.zx',0,5);
HE:=stkindi('','YY.MA5',0,5);
HF:=stkindi('','YY.MA10',0,5);
HG:=stkindi('','YY.MA20',0,5);
HI:=stkindi('','YY.MA40',0,5);
HO:=stkindi('','YY.HH',0,5);
HP:=stkindi('','YY.LL',0,5);
HN:=stkindi('','YY.CL',0,5);
60DUO:=HP<MIN(MIN(HE,HF),MIN(HG,HI))&&CROSS(HN,HE)&&CROSS(HN,HF)&&CROSS(HN,HG)&&CROSS(HN,HI)&&HF>REF(HF,1)&&HG>REF(HG,1);
60KONG:=HO>MAX(MAX(HE,HF),MAX(HG,HI))&&CROSS(HE,HN)&&CROSS(HF,HN)&&CROSS(HG,HN)&&CROSS(HI,HN)&&HF<REF(HF,1)&&HG<REF(HG,1);
IF(HA>0,HA,NULL),CIRCLEDOT,COLORYELLOW;variable:bj=0;
zx:=stkindi('','YY.zx',0,5);
if zx=1 then bj:=1;
if zx=-1 then bj:=-1;
MA5:MA(CLOSE,5);
MA10:MA(CLOSE,10);
MA20:MA(CLOSE,20);
MA40:MA(CLOSE,40);
SS:=SAR(P,STEP,MAXP);
SZ:=SARTURN(10,4,20);
A:=MA5>=MA10&&MA10>MA20&&MA5>REF(MA5,1)&&MA10>REF(MA10,1); //4条均线多头排列,且价格在均线之上
B:=MA5<=MA10&&MA10<MA20&&MA5<REF(MA5,1)&&MA10<REF(MA10,1) ; //4条均线空头排列,且价格在均线之下
AA:=MA10>MA20&&MA20>MA40&&MA20>REF(MA20,1)&&MA40>REF(MA40,1);
BB:=MA10<MA20&&MA20<MA40&&MA20<REF(MA20,1)&&MA40<REF(MA40,1);
CC:=LOW<MIN(MIN(MA5,MA10),MIN(MA20,MA40))&&CROSS(CLOSE,MA5)&&CROSS(CLOSE,10)&&CROSS(CLOSE,20)&&CROSS(CLOSE,40)&&MA10>REF(MA10,1)&&MA20>REF(MA20,1);
DD:=HIGH>MAX(MAX(MA5,MA10),MAX(MA20,MA40))&&CROSS(MA5,CLOSE)&&CROSS(MA10,CLOSE)&&CROSS(MA20,CLOSE)&&CROSS(MA40,CLOSE)&&MA10<REF(MA10,1)&&MA20<REF(MA20,1);KAA:=IF(AA,1,0);
KBB:=IF(BB,1,0);
D:=(HIGH+LOW+O+2*C)/5;IF BJ=1&&HB&&A&&ISUP&&CLOSE>REF(L+(H-L)*2/3,1) AND SS>0&& HOLDING=0 THEN
开多m:BUY(1,1,LIMITR,CLOSE); //开多
IF HOLDING>0&&CROSS(MA10,MA5) THEN平多g:SELL(1,HOLDING,LIMITR,CLOSE); //平多
IF HC&&bj=-1&&b&&ISDOWN&&CLOSE<REF(L+(H-L)/3,1) AND HOLDING=0 THEN开空f: BUYSHORT(1,1,LIMITR,CLOSE); //开空单
IF HOLDING<0 and CROSS(MA5,MA10) THEN
平空e:SELLSHORT(1,HOLDING,LIMITR,CLOSE); //平空
H11:=HIGH;
L11:=LOW;
A:=IFELSE(HIGH>=REF(HIGH,1)&&HIGH>=REF(HIGH,2)&&HIGH>=REF(HIGH,3) &&HIGH>=REF(HIGH,4)&&HIGH>=REF(HIGH,5),LOW,0);
B:=IFELSE(LOW<=REF(LOW,1)&&LOW<=REF(LOW,2)&&LOW<=REF(LOW,3) &&LOW<=REF(LOW,4)&&LOW<=REF(LOW,5),HIGH,888888);
P1:=IFELSE(A>REF(L11,1),REF(L11,1),0);
P2:=IFELSE(A>REF(L11,2)&&A<=REF(L11,1),REF(L,2),0);
P3:=IFELSE(A>REF(L11,3)&&A<=REF(L11,1)&&A<=REF(L11,2),REF(L11,3),0);
P4:=IFELSE(A>REF(L11,4)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3),REF(L11,4),0);
P5:=IFELSE(A>REF(L11,5)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4),REF(L11,5),0);
P6:=IFELSE(A>REF(L11,6)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5),REF(L11,6),0);
P7:=IFELSE(A>REF(L11,7)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6),REF(L11,7),0);
P8:=IFELSE(A>REF(L11,8)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7),REF(L11,8),0);
P9:=IFELSE(A>REF(L11,9)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7)&&A<=REF(L11,8),REF(L11,9),0);
P10:=IFELSE(A>REF(L11,10)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7)&&A<=REF(L11,8)&&A<=REF(L11,9),REF(L11,10),0);
AA:=P1+P2+P3+P4+P5+P6+P7+P8+P9+P10;
PP1:=IFELSE(AA>REF(L11,1),REF(L11,1),0);
PP2:=IFELSE(AA>REF(L11,2)&&AA<=REF(L11,1),REF(L11,2),0);
PP3:=IFELSE(AA>REF(L11,3)&&AA<=REF(L11,1)&&AA<=REF(L11,2),REF(L11,3),0);
PP4:=IFELSE(AA>REF(L11,4)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3),REF(L11,4),0);
PP5:=IFELSE(AA>REF(L11,5)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4),REF(L11,5),0);
PP6:=IFELSE(AA>REF(L11,6)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5),REF(L11,6),0);
PP7:=IFELSE(AA>REF(L11,7)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6),REF(L11,7),0);
PP8:=IFELSE(AA>REF(L11,8)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7),REF(L11,8),0);
PP9:=IFELSE(AA>REF(L11,9)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7)&&AA<=REF(L11,8),REF(L11,9),0);
PP10:=IFELSE(AA>REF(L11,10)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7)&&AA<=REF(L11,8)&&AA<=REF(L11,9),REF(L11,10),0);
AAA:=PP1+PP2+PP3+PP4+PP5+PP6+PP7+PP8+PP9+PP10;
C11:=VALUEWHEN(AAA>0,AAA);
T1:=IFELSE(B<REF(H11,1),REF(H11,1),0);
T2:=IFELSE(B<REF(H11,2)&&B>=REF(H11,1),REF(H11,2),0);
T3:=IFELSE(B<REF(H11,3)&&B>=REF(H11,1)&&B>=REF(H11,2),REF(H11,3),0);
T4:=IFELSE(B<REF(H11,4)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3),REF(H11,4),0);
T5:=IFELSE(B<REF(H11,5)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4),REF(H11,5),0);
T6:=IFELSE(B<REF(H11,6)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5),REF(H11,6),0);
T7:=IFELSE(B<REF(H11,7)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6),REF(H11,7),0);
T8:=IFELSE(B<REF(H11,8)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7),REF(H11,8),0);
T9:=IFELSE(B<REF(H11,9)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7)&&B>=REF(H11,8),REF(H11,9),0);
T10:=IFELSE(B<REF(H11,10)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7)&&B>=REF(H11,8)&&B>=REF(H11,9),REF(H11,10),0);
BB:=IFELSE((T1+T2+T3+T4+T5+T6+T7+T8+T9+T10)=0,888888,T1+T2+T3+T4+T5+T6+T7+T8+T9+T10);
TT1:=IFELSE(BB<REF(H11,1),REF(H11,1),0);
TT2:=IFELSE(BB<REF(H11,2)&&BB>=REF(H11,1),REF(H11,2),0);
TT3:=IFELSE(BB<REF(H11,3)&&BB>=REF(H11,1)&&BB>=REF(H11,2),REF(H11,3),0);
TT4:=IFELSE(BB<REF(H11,4)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3),REF(H11,4),0);
TT5:=IFELSE(BB<REF(H11,5)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4),REF(H11,5),0);
TT6:=IFELSE(BB<REF(H11,6)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5),REF(H11,6),0);
TT7:=IFELSE(BB<REF(H11,7)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6),REF(H11,7),0);
TT8:=IFELSE(BB<REF(H11,8)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7),REF(H11,8),0);
TT9:=IFELSE(BB<REF(H11,9)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7)&&BB>=REF(H11,8),REF(H11,9),0);
TT10:=IFELSE(BB<REF(H11,10)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7)&&BB>=REF(H11,8)&&BB>=REF(H11,9),REF(H11,10),0);
BBB:=TT1+TT2+TT3+TT4+TT5+TT6+TT7+TT8+TT9+TT10;
D:=VALUEWHEN(BBB>0,BBB);
UD:=IFELSE(CLOSE>D&&REF(CLOSE,1)<=D,1,IFELSE(CLOSE<C11&&REF(CLOSE,1)>=C11,-3,0));
K:=VALUEWHEN(UD<>0,UD);
G:=IFELSE(K=1,C11,D),COLORRED;
G1:=VALUEWHEN(ISLASTBAR,G);
TMP:=-K;TMP1:=REF(TMP,1)<0;
TMP2:=REF(TMP,1)>0;
//TMP>0,SPK;
//TMP<=0,BPK;IF HOLDING=0 THEN BEGIN //若持仓为0
IF TMP<=0&&TMP2 THEN //且TMP<=0
开多d:BUY(1,1,LIMITR,CLOSE); //开多单
END
IF HOLDING=0 THEN BEGIN //若持仓为0
IF TMP>0&&TMP1 THEN //且TMP>0
开空c: BUYSHORT(1,1,LIMITR,CLOSE); //开空单
ENDIF HOLDING>0 THEN BEGIN //若持有多单
IF TMP>0&&TMP1 THEN BEGIN //且TMP>0
平多a:SELL(1,HOLDING,LIMITR,CLOSE); //平多单
开空a:BUYSHORT(1,1,LIMITR,CLOSE); //开空单
END
END
IF HOLDING<0 THEN BEGIN //若持有空单
IF TMP<=0&&TMP2 THEN BEGIN //且TMP<=0
平多b: SELLSHORT(1,HOLDING,LIMITR,CLOSE); //平空单
开多b: BUY(1,1,LIMITR,CLOSE); //开多单
END
END修改后的代码为:(主要做了出信号a b 和f后三个k线内达到5日线开仓)依旧用轮询模式
HA:=stkindi('','YY.ss',0,5,-1);
HB:=stkindi('','YY.60up',0,5,-1);
HC:=stkindi('','YY.60down',0,5,-1);
HD:=stkindi('','YY.zx',0,5,-1);
HE:=stkindi('','YY.MA5',0,5,-1);
HF:=stkindi('','YY.MA10',0,5,-1);
HG:=stkindi('','YY.MA20',0,5,-1);
HI:=stkindi('','YY.MA40',0,5,-1);
HO:=stkindi('','YY.HH',0,5,-1);
HP:=stkindi('','YY.LL',0,5,-1);
HN:=stkindi('','YY.CL',0,5,-1);
60DUO:=HP<MIN(MIN(HE,HF),MIN(HG,HI))&&CROSS(HN,HE)&&CROSS(HN,HF)&&CROSS(HN,HG)&&CROSS(HN,HI)&&HF>REF(HF,1)&&HG>REF(HG,1);
60KONG:=HO>MAX(MAX(HE,HF),MAX(HG,HI))&&CROSS(HE,HN)&&CROSS(HF,HN)&&CROSS(HG,HN)&&CROSS(HI,HN)&&HF<REF(HF,1)&&HG<REF(HG,1);
IF(HA>0,HA,NULL),CIRCLEDOT,COLORYELLOW;variable:bj=0;
zx:=stkindi('','YY.zx',0,5);
if zx=1 then bj:=1;
if zx=-1 then bj:=-1;
MA5:MA(CLOSE,5);
MA10:MA(CLOSE,10);
MA20:MA(CLOSE,20);
MA40:MA(CLOSE,40);
SS:=SAR(P,STEP,MAXP);
SZ:=SARTURN(10,4,20);
A:=MA5>=MA10&&MA10>MA20&&MA5>REF(MA5,1)&&MA10>REF(MA10,1); //4条均线多头排列,且价格在均线之上
B:=MA5<=MA10&&MA10<MA20&&MA5<REF(MA5,1)&&MA10<REF(MA10,1) ; //4条均线空头排列,且价格在均线之下
AA:=MA10>MA20&&MA20>MA40&&MA20>REF(MA20,1)&&MA40>REF(MA40,1);
BB:=MA10<MA20&&MA20<MA40&&MA20<REF(MA20,1)&&MA40<REF(MA40,1);
CC:=LOW<MIN(MIN(MA5,MA10),MIN(MA20,MA40))&&CROSS(CLOSE,MA5)&&CROSS(CLOSE,10)&&CROSS(CLOSE,20)&&CROSS(CLOSE,40)&&MA10>REF(MA10,1)&&MA20>REF(MA20,1);
DD:=HIGH>MAX(MAX(MA5,MA10),MAX(MA20,MA40))&&CROSS(MA5,CLOSE)&&CROSS(MA10,CLOSE)&&CROSS(MA20,CLOSE)&&CROSS(MA40,CLOSE)&&MA10<REF(MA10,1)&&MA20<REF(MA20,1);KAA:=IF(AA,1,0);
KBB:=IF(BB,1,0);
D:=(HIGH+LOW+O+2*C)/5;IF BJ=1&&HB&&A&&ISUP&&CLOSE>REF(L+(H-L)*2/3,1) AND SS>0&& HOLDING=0 THEN
开仓m:BUY(1,1,LIMITR,CLOSE); //开多
IF HOLDING>0&&CROSS(MA10,MA5) and ma10>ma20 and ma10>ma40 THEN平仓g: SELL(1,HOLDING,LIMITR,CLOSE); //平多
variable:fj=0;
开仓f:= HC&&bj=-1&&b&&ISDOWN&&CLOSE<REF(L+(H-L)/3,1);
if barslast(开仓f)<=3 and barslast(开仓f)>0 and h>=ma5 and holding=0 and fj=0 then begin
开仓f1:BUYSHORT(1,1,LIMITR,c); //开空单
fj:=1;
end
if barslast(开仓f)>4 then fj:=0;
IF HOLDING<0 AND CROSS(MA(C,5),MA(C,10)) AND (MA(C,5)<MA(C,20) and (MA(C,5)<MA(C,40))) THEN
平仓e: SELLSHORT(1,HOLDING,LIMITR,CLOSE);
H11:=HIGH;
L11:=LOW;
A:=IFELSE(HIGH>=REF(HIGH,1)&&HIGH>=REF(HIGH,2)&&HIGH>=REF(HIGH,3) &&HIGH>=REF(HIGH,4)&&HIGH>=REF(HIGH,5),LOW,0);
B:=IFELSE(LOW<=REF(LOW,1)&&LOW<=REF(LOW,2)&&LOW<=REF(LOW,3) &&LOW<=REF(LOW,4)&&LOW<=REF(LOW,5),HIGH,888888);
P1:=IFELSE(A>REF(L11,1),REF(L11,1),0);
P2:=IFELSE(A>REF(L11,2)&&A<=REF(L11,1),REF(L,2),0);
P3:=IFELSE(A>REF(L11,3)&&A<=REF(L11,1)&&A<=REF(L11,2),REF(L11,3),0);
P4:=IFELSE(A>REF(L11,4)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3),REF(L11,4),0);
P5:=IFELSE(A>REF(L11,5)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4),REF(L11,5),0);
P6:=IFELSE(A>REF(L11,6)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5),REF(L11,6),0);
P7:=IFELSE(A>REF(L11,7)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6),REF(L11,7),0);
P8:=IFELSE(A>REF(L11,8)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7),REF(L11,8),0);
P9:=IFELSE(A>REF(L11,9)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7)&&A<=REF(L11,8),REF(L11,9),0);
P10:=IFELSE(A>REF(L11,10)&&A<=REF(L11,1)&&A<=REF(L11,2)&&A<=REF(L11,3)&&A<=REF(L11,4)&&A<=REF(L11,5)&&A<=REF(L11,6)&&A<=REF(L11,7)&&A<=REF(L11,8)&&A<=REF(L11,9),REF(L11,10),0);
AA:=P1+P2+P3+P4+P5+P6+P7+P8+P9+P10;
PP1:=IFELSE(AA>REF(L11,1),REF(L11,1),0);
PP2:=IFELSE(AA>REF(L11,2)&&AA<=REF(L11,1),REF(L11,2),0);
PP3:=IFELSE(AA>REF(L11,3)&&AA<=REF(L11,1)&&AA<=REF(L11,2),REF(L11,3),0);
PP4:=IFELSE(AA>REF(L11,4)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3),REF(L11,4),0);
PP5:=IFELSE(AA>REF(L11,5)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4),REF(L11,5),0);
PP6:=IFELSE(AA>REF(L11,6)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5),REF(L11,6),0);
PP7:=IFELSE(AA>REF(L11,7)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6),REF(L11,7),0);
PP8:=IFELSE(AA>REF(L11,8)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7),REF(L11,8),0);
PP9:=IFELSE(AA>REF(L11,9)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7)&&AA<=REF(L11,8),REF(L11,9),0);
PP10:=IFELSE(AA>REF(L11,10)&&AA<=REF(L11,1)&&AA<=REF(L11,2)&&AA<=REF(L11,3)&&AA<=REF(L11,4)&&AA<=REF(L11,5)&&AA<=REF(L11,6)&&AA<=REF(L11,7)&&AA<=REF(L11,8)&&AA<=REF(L11,9),REF(L11,10),0);
AAA:=PP1+PP2+PP3+PP4+PP5+PP6+PP7+PP8+PP9+PP10;
C11:=VALUEWHEN(AAA>0,AAA);
T1:=IFELSE(B<REF(H11,1),REF(H11,1),0);
T2:=IFELSE(B<REF(H11,2)&&B>=REF(H11,1),REF(H11,2),0);
T3:=IFELSE(B<REF(H11,3)&&B>=REF(H11,1)&&B>=REF(H11,2),REF(H11,3),0);
T4:=IFELSE(B<REF(H11,4)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3),REF(H11,4),0);
T5:=IFELSE(B<REF(H11,5)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4),REF(H11,5),0);
T6:=IFELSE(B<REF(H11,6)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5),REF(H11,6),0);
T7:=IFELSE(B<REF(H11,7)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6),REF(H11,7),0);
T8:=IFELSE(B<REF(H11,8)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7),REF(H11,8),0);
T9:=IFELSE(B<REF(H11,9)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7)&&B>=REF(H11,8),REF(H11,9),0);
T10:=IFELSE(B<REF(H11,10)&&B>=REF(H11,1)&&B>=REF(H11,2)&&B>=REF(H11,3)&&B>=REF(H11,4)&&B>=REF(H11,5)&&B>=REF(H11,6)&&B>=REF(H11,7)&&B>=REF(H11,8)&&B>=REF(H11,9),REF(H11,10),0);
BB:=IFELSE((T1+T2+T3+T4+T5+T6+T7+T8+T9+T10)=0,888888,T1+T2+T3+T4+T5+T6+T7+T8+T9+T10);
TT1:=IFELSE(BB<REF(H11,1),REF(H11,1),0);
TT2:=IFELSE(BB<REF(H11,2)&&BB>=REF(H11,1),REF(H11,2),0);
TT3:=IFELSE(BB<REF(H11,3)&&BB>=REF(H11,1)&&BB>=REF(H11,2),REF(H11,3),0);
TT4:=IFELSE(BB<REF(H11,4)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3),REF(H11,4),0);
TT5:=IFELSE(BB<REF(H11,5)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4),REF(H11,5),0);
TT6:=IFELSE(BB<REF(H11,6)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5),REF(H11,6),0);
TT7:=IFELSE(BB<REF(H11,7)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6),REF(H11,7),0);
TT8:=IFELSE(BB<REF(H11,8)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7),REF(H11,8),0);
TT9:=IFELSE(BB<REF(H11,9)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7)&&BB>=REF(H11,8),REF(H11,9),0);
TT10:=IFELSE(BB<REF(H11,10)&&BB>=REF(H11,1)&&BB>=REF(H11,2)&&BB>=REF(H11,3)&&BB>=REF(H11,4)&&BB>=REF(H11,5)&&BB>=REF(H11,6)&&BB>=REF(H11,7)&&BB>=REF(H11,8)&&BB>=REF(H11,9),REF(H11,10),0);
BBB:=TT1+TT2+TT3+TT4+TT5+TT6+TT7+TT8+TT9+TT10;
D:=VALUEWHEN(BBB>0,BBB);
UD:=IFELSE(CLOSE>D&&REF(CLOSE,1)<=D,1,IFELSE(CLOSE<C11&&REF(CLOSE,1)>=C11,-3,0));
K:=VALUEWHEN(UD<>0,UD);
G:=IFELSE(K=1,C11,D),COLORRED;
G1:=VALUEWHEN(ISLASTBAR,G);
TMP:=-K;TMP1:=REF(TMP,1)<0;
TMP2:=REF(TMP,1)>0;
//TMP>0,SPK;
//TMP<=0,BPK;
IF TMP>0&&TMP1 and HOLDING>0 THEN BEGIN // 若持有多单 且TMP>0
平仓a:SELL(1,HOLDING,LIMITR,CLOSE); //平多单
end
variable:aj=0;
开仓a: = TMP>0&&TMP1 ;
if barslast(开仓a)<=3 and barslast(开仓a)>0 and h>=ma5 and holding=0 and aj=0 then begin
开仓a1:BUYSHORT(1,1,LIMITR,c); //开空单 tmp>0
aj:=1;
end
if barslast(开仓f)>4 then aj:=0;
IF TMP<0&&TMP2 and HOLDING<0 THEN BEGIN // 若持有空单 且TMP<0
平仓b:SELLSHORT(1,HOLDING,LIMITR,CLOSE); //平空单
end
variable:bj=0;
开仓b: = TMP<0&&TMP2 ;
if barslast(开仓b)<=3 and barslast(开仓b)>0 and LOW<=ma5 and holding=0 and bj=0 then begin
开仓b1:BUY(1,1,LIMITR,c); //开多单 tmp>0
bj:=1;
end
if barslast(开仓f)>4 then bj:=0; - 金字塔客服:
清指出部分不出现的信号是哪些
- 用户回复:
b信号,改过后应该出b1,而有时候不出 ,能不能重新帮我做个排序,实现上面的要求!
- 网友回复:
模型为,一个正常的买卖模型,后来加入了下半部分的顶底指标,请求设置,买卖的排序,或者求助帮忙检查下,其它代码有无错误,为啥有的信号,比如b1 该出时候不出,有的位置满足也出了。这个是不是holding的缘故没,把这个指标成功嵌入?
- 网友回复: 你发张图来解释说明一下什么是“b1该出现但是没出现”
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容