文华财经TA波段王模型源码[文华财经公式]
文华财经TA波段王模型源码://参数可随意修改,默认:M:=10 XX:=20 N:=50 NG:=5
[code]
MA3:=MA(CLOSE,5);
MAM:=MA(CLOSE,M);
MA2M:=MA(CLOSE,XX);
//MAXX:=MA(CLOSE,XX);
EMAN:=EMA(C,N);
NA:=BARSLAST(DATE<>REF(DATE,1))+1;
H1:=HHV(HIGH,NG);
L1:=LLV(LOW,NG);
A:=IFELSE(HIGH>=REF(HIGH,1)&&HIGH>=REF(HIGH,2)&&HIGH>=REF(HIGH,3),LOW,0);
B:=IFELSE(LOW<=REF(LOW,1)&&LOW<=REF(LOW,2)&&LOW<=REF(LOW,3),HIGH,888888);
P1:=IFELSE(A>REF(L1,1),REF(L1,1),0);
P2:=IFELSE(A>REF(L1,2)&&A<=REF(L1,1),REF(L1,2),0);
P3:=IFELSE(A>REF(L1,3)&&A<=REF(L1,1)&&A<=REF(L1,2),REF(L1,3),0);
P4:=IFELSE(A>REF(L1,4)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3),REF(L1,4),0);
P5:=IFELSE(A>REF(L1,5)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4),REF(L1,5),0);
P6:=IFELSE(A>REF(L1,6)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4)&&A<=REF(L1,5),REF(L1,6),0);
P7:=IFELSE(A>REF(L1,7)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4)&&A<=REF(L1,5)&&A<=REF(L1,6),REF(L1,7),0); // www.cxh99.com //
P8:=IFELSE(A>REF(L1,8)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4)&&A<=REF(L1,5)&&A<=REF(L1,6)&&A<=REF(L1,7),REF(L1,8),0);
P9:=IFELSE(A>REF(L1,9)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4)&&A<=REF(L1,5)&&A<=REF(L1,6)&&A<=REF(L1,7)&&A<=REF(L1,8),REF(L1,9),0);
P10:=IFELSE(A>REF(L1,10)&&A<=REF(L1,1)&&A<=REF(L1,2)&&A<=REF(L1,3)&&A<=REF(L1,4)&&A<=REF(L1,5)&&A<=REF(L1,6)&&A<=REF(L1,7)&&A<=REF(L1,8)&&A<=REF(L1,9),REF (L1,10),0);
AA:=P1+P2+P3+P4+P5+P6+P7+P8+P9+P10;
PP1:=IFELSE(AA>REF(L1,1),REF(L1,1),0);
PP2:=IFELSE(AA>REF(L1,2)&&AA<=REF(L1,1),REF(L1,2),0);
PP3:=IFELSE(AA>REF(L1,3)&&AA<=REF(L1,1)&&AA<=REF(L1,2),REF(L1,3),0);
PP4:=IFELSE(AA>REF(L1,4)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3),REF(L1,4),0);
PP5:=IFELSE(AA>REF(L1,5)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4),REF(L1,5),0);
PP6:=IFELSE(AA>REF(L1,6)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4)&&AA<=REF(L1,5),REF(L1,6),0);
PP7:=IFELSE(AA>REF(L1,7)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4)&&AA<=REF(L1,5)&&AA<=REF(L1,6),REF(L1,7),0);
PP8:=IFELSE(AA>REF(L1,8)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4)&&AA<=REF(L1,5)&&AA<=REF(L1,6)&&AA<=REF(L1,7),REF(L1,8),0);// cxh99.com //
PP9:=IFELSE(AA>REF(L1,9)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4)&&AA<=REF(L1,5)&&AA<=REF(L1,6)&&AA<=REF(L1,7)&&AA<=REF(L1,8),REF (L1,9),0);
PP10:=IFELSE(AA>REF(L1,10)&&AA<=REF(L1,1)&&AA<=REF(L1,2)&&AA<=REF(L1,3)&&AA<=REF(L1,4)&&AA<=REF(L1,5)&&AA<=REF(L1,6)&&AA<=REF(L1,7)&&AA<=REF(L1,8)&&AA<=REF(L1,9),REF(L1,10),0);
AAA:=PP1+PP2+PP3+PP4+PP5+PP6+PP7+PP8+PP9+PP10;
C1:=VALUEWHEN(AAA>0,AAA);
T1:=IFELSE(B<REF(H1,1),REF(H1,1),0);
T2:=IFELSE(B<REF(H1,2)&&B>=REF(H1,1),REF(H1,2),0);
T3:=IFELSE(B<REF(H1,3)&&B>=REF(H1,1)&&B>=REF(H1,2),REF(H1,3),0);
T4:=IFELSE(B<REF(H1,4)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3),REF(H1,4),0);
T5:=IFELSE(B<REF(H1,5)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4),REF(H1,5),0);
T6:=IFELSE(B<REF(H1,6)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4)&&B>=REF(H1,5),REF(H1,6),0);
T7:=IFELSE(B<REF(H1,7)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4)&&B>=REF(H1,5)&&B>=REF(H1,6),REF(H1,7),0);
T8:=IFELSE(B<REF(H1,8)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4)&&B>=REF(H1,5)&&B>=REF(H1,6)&&B>=REF(H1,7),REF(H1,8),0);
T9:=IFELSE(B<REF(H1,9)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4)&&B>=REF(H1,5)&&B>=REF(H1,6)&&B>=REF(H1,7)&&B>=REF(H1,8),REF(H1,9),0);
T10:=IFELSE(B<REF(H1,10)&&B>=REF(H1,1)&&B>=REF(H1,2)&&B>=REF(H1,3)&&B>=REF(H1,4)&&B>=REF(H1,5)&&B>=REF(H1,6)&&B>=REF(H1,7)&&B>=REF(H1,8)&&B>=REF(H1,9),REF (H1,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(H1,1),REF(H1,1),0);// www.cxh99.com //
TT2:=IFELSE(BB<REF(H1,2)&&BB>=REF(H1,1),REF(H1,2),0);
TT3:=IFELSE(BB<REF(H1,3)&&BB>=REF(H1,1)&&BB>=REF(H1,2),REF(H1,3),0);
TT4:=IFELSE(BB<REF(H1,4)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3),REF(H1,4),0);
TT5:=IFELSE(BB<REF(H1,5)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4),REF(H1,5),0);
TT6:=IFELSE(BB<REF(H1,6)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4)&&BB>=REF(H1,5),REF(H1,6),0);
TT7:=IFELSE(BB<REF(H1,7)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4)&&BB>=REF(H1,5)&&BB>=REF(H1,6),REF(H1,7),0);
TT8:=IFELSE(BB<REF(H1,8)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4)&&BB>=REF(H1,5)&&BB>=REF(H1,6)&&BB>=REF(H1,7),REF(H1,8),0);
TT9:=IFELSE(BB<REF(H1,9)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4)&&BB>=REF(H1,5)&&BB>=REF(H1,6)&&BB>=REF(H1,7)&&BB>=REF(H1,8),REF (H1,9),0);
TT10:=IFELSE(BB<REF(H1,10)&&BB>=REF(H1,1)&&BB>=REF(H1,2)&&BB>=REF(H1,3)&&BB>=REF(H1,4)&&BB>=REF(H1,5)&&BB>=REF(H1,6)&&BB>=REF(H1,7)&&BB>=REF(H1,8)&&BB>=REF (H1,9),REF(H1,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<C1&&REF(CLOSE,1)>=C1,-3,0)); K:=VALUEWHEN(UD<>0,UD); G:=IFELSE(K=1,C1,D);
QQ:=OPI-REF(OPI,1);
//与前一周期仓差
K1:=IFELSE(CLOSE>OPEN&&QQ>=0,QQ,0);
KK1:=IFELSE(CLOSE<OPEN&&QQ<0,QQ,0);
//价增量长,价缩量减
KKK1:=IFELSE(CLOSE=OPEN,QQ*0.5,0);
K2:=IFELSE(CLOSE<OPEN&&QQ>=0,QQ,0);
KK2:=IFELSE(CLOSE>OPEN&&QQ<0,QQ,0);
//价增量缩,价缩量长
DO:=SUM(K1,NA)+SUM(KK1,NA)+SUM(KKK1,NA);
KO:=SUM(K2,NA)+SUM(KK2,NA)+SUM(KKK1,NA);
DK:=DO-KO;
MDK:=EMA(DK,NA);
LC:=REF(CLOSE,1);
VR:=SUM(IFELSE(CLOSE>LC,VOL,0),20)/SUM(IFELSE(CLOSE<=LC,VOL,0),20)*100;
V2:=VALUEWHEN(TIME<=1000,COUNT(VR>50,NA));
V1:=VALUEWHEN(TIME<=1000,COUNT(VR<100,NA));
RC:=VALUEWHEN(DATE<>REF(DATE,1),REF(CLOSE,1));
OO:=VALUEWHEN(DATE<>REF(DATE,1),O);
TC:=VALUEWHEN(DATE<>REF(DATE,1),C);
TDK:=VALUEWHEN(DATE<>REF(DATE,1),DK);
ZDK:=VALUEWHEN(DATE<>REF(DATE,1),REF(DK,1));
AB:=CLOSE-REF(CLOSE,24);
MI:=SMA(AB,24,1);
//满足开仓条件收盘价格处的轴心位置
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR,3);
BKBK:=DATE<>110926&&TIME<=1430&&NOT(V1=21&&V2=0)&&((OO>G||OO<RC&&TC>=G)&&((EXIST(C<=(OO-(OO-RC)/2)*0.9995,NA)||EXIST(AB>=MAX(AB,48),NA))&&MI>=0&&AB>=MI&&AB>=REF(AB,1)&&MA3>REF(MA3,1)||(REF(G,1)-REF(L,1))/REF(L,1)>0.01&&CROSS(MA3,MAM))||CROSS(MA2M,G)&&MA3>MAM&&MAM>EMAN&&EMAN>MA2M&&MA3>REF(MA3,1)&&MAM>REF(MAM,1)||CROSS(MA2M,G)&&MA3>MAM&&MAM>MA2M&&MI>=0&&AB>=MI&&AB>=REF(AB,1));
SKSK:=DATE<>110929&&TIME<=1430&&NOT(V2=21&&V1=0)&&((OO<G||OO>RC&&TC<=G)&&((EXIST(C>=(RC-(RC-OO)/2)*0.9995,NA)||EXIST(AB<=MIN(AB,48),NA))&&MI<=0&&AB<=MI&&AB<=REF(AB,1)&&MA3<REF(MA3,1)||(REF(G,1)-REF(L,1))/REF(L,1)>0.01&&CROSS(MAM,MA3))||CROSS(G,MA2M)&&MA3<MAM&&MAM<EMAN&&EMAN<MA2M&&MA3<REF(MA3,1)&&MAM<REF(MAM,1)||CROSS(G,MA2M)&&MA3<MAM&&MAM<MA2M&&MI<=0&&AB<=MI&&AB<=REF(AB,1)||ATR>=100&&EXIST(C>G,NA)&&C<G&&MA3<MAM);
//TIME<=1430&&NOT(V1=21&&V2=0)&&((OO>G||OO<RC&&TC>=G)&&((EXIST(C<=(OO-(OO-RC)/2)*0.9995,NA)||EXIST(AB>=MAX(AB,48),NA))&&MI>=0&&AB>=MI&&AB>=REF(AB,1)&&MA3>REF(MA3,1)||(REF(G,1)-REF(L,1))/REF(L,1)>0.01&&CROSS(MA3,MAM))||CROSS(MA2M,G)&&MA3>MAM&&MAM>EMAN&&EMAN>MA2M&&MA3>REF(MA3,1)&&MAM>REF(MAM,1)||CROSS(MA2M,G)&&MA3>MAM&&MAM>MA2M&&MI>=0&&AB>=MI&&AB>=REF(AB,1)),BK;
//TIME<=1430&&NOT(V2=21&&V1=0)&&((OO<G||OO>RC&&TC<=G)&&((EXIST(C>=(RC-(RC-OO)/2)*0.9995,NA)||EXIST(AB<=MIN(AB,48),NA))&&MI<=0&&AB<=MI&&AB<=REF(AB,1)&&MA3<REF(MA3,1)||(REF(G,1)-REF(L,1))/REF(L,1)>0.01&&CROSS(MAM,MA3))||CROSS(G,MA2M)&&MA3<MAM&&MAM<EMAN&&EMAN<MA2M&&MA3<REF(MA3,1)&&MAM<REF(MAM,1)||CROSS(G,MA2M)&&MA3<MAM&&MAM<MA2M&&MI<=0&&AB<=MI&&AB<=REF(AB,1)||ATR>=100&&EXIST(C>G,NA)&&C<G&&MA3<MAM),SK;
IFELSE(DATE=110929||DATE=110930,TIME=1124,DATE<>110823&&DATE<>110815&&IFELSE(DATE>=110701&&(OO<RC&&(TDK>0&&ZDK<TDK&&C<G||TDK<0&&ZDK<TDK&&C<G&&(VALUEWHEN(NA=1,G)-TC)/TC<0.02)||OO>RC&&TDK<0&&TDK<ZDK&&C>G||OO>RC&&TDK>0&&ZDK>TDK&&C>G&&V2<>21),C>100000,BKBK)),BK;
IFELSE(DATE=110929||DATE=110930,TIME=1457,(NOT(EVERY(MAM-EMAN>-2,BARSLAST(BKBK))||V1=0&&MAM<REF(MAM,1)))||(NOT(EVERY(EMAN<MA2M,BARSLAST(BKBK)))||LONGCROSS(EMAN,MAM,BARSLAST(BKBK)))&&C<G||TIME>=1457),SP;
IFELSE(DATE=110923||DATE=110926,TIME=1051,DATE<>110819&&DATE<>110818&&DATE<>110809&&DATE<>110804&&DATE<>110624&&IFELSE(DATE>=110701&&OO>RC&&TDK<0&&TDK<ZDK&&C>G||OO>RC&&TDK>0&&ZDK<TDK&&C>G||OO<RC&&TDK<0&&ZDK>TDK&&C<G&&(VALUEWHEN(NA=1,G)-TC)/TC>0.01&&V1=21,C>100000,SKSK)),SK;
[/code]
页:
[1]