交易策略源码:
{K:10,M:5}
A:=SUM( IF(CLOSE>REF(CLOSE,1), VOL/CLOSE,0), K);
当收大于昨收时成交量 / 收盘价的K周期的的总和
B:=SUM( IF(CLOSE=REF(HIGH,1)HIGH>=REF(HIGH,2)HIGH>=REF(HIGH,3),LOW,0);
B:=IF(LOWREF(L,1),REF(L,1),0);
P2:=IF(A>REF(L,2)AREF(L,3)AREF(L,4)AREF(L,5)AREF(L,6)AREF(L,7)AREF(L,8)AREF(L,9)AREF(L,10)AREF(L,1),REF(L,1),0);
PP2:=IF(AA>REF(L,2)AAREF(L,3)AAREF(L,4)AAREF(L,5)AAREF(L,6)AAREF(L,7)AAREF(L,8)AAREF(L,9)AAREF(L,10)AA0,AAA);
T1:=IF(B=REF(H,1),REF(H,2),0);
T3:=IF(B=REF(H,1)B>=REF(H,2),REF(H,3),0);
T4:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3),REF(H,4),0);
T5:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4),REF(H,5),0);
T6:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4)B>=REF(H,5),REF(H,6),0);
T7:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4)B>=REF(H,5)B>=REF(H,6),REF(H,7),0);
T8:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4)B>=REF(H,5)B>=REF(H,6)B>=REF(H,7),REF(H,8),0);
T9:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4)B>=REF(H,5)B>=REF(H,6)B>=REF(H,7)B>=REF(H,8),REF(H,9),0);
T10:=IF(B=REF(H,1)B>=REF(H,2)B>=REF(H,3)B>=REF(H,4)B>=REF(H,5)B>=REF(H,6)B>=REF(H,7)B>=REF(H,8)B>=REF(H,9),REF (H,10),0);
BB:=IF((T1+T2+T3+T4+T5+T6+T7+T8+T9+T10)=0,888888,T1+T2+T3+T4+T5+T6+T7+T8+T9+T10);
TT1:=IF(BB=REF(H,1),REF(H,2),0);
TT3:=IF(BB=REF(H,1)BB>=REF(H,2),REF(H,3),0);
TT4:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3),REF(H,4),0);
TT5:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4),REF(H,5),0);
TT6:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4)BB>=REF(H,5),REF(H,6),0);
TT7:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4)BB>=REF(H,5)BB>=REF(H,6),REF(H,7),0);
TT8:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4)BB>=REF(H,5)BB>=REF(H,6)BB>=REF(H,7),REF(H,8),0);
TT9:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4)BB>=REF(H,5)BB>=REF(H,6)BB>=REF(H,7)BB>=REF(H,8),REF (H,9),0);
TT10:=IF(BB=REF(H,1)BB>=REF(H,2)BB>=REF(H,3)BB>=REF(H,4)BB>=REF(H,5)BB>=REF(H,6)BB>=REF(H,7)BB>=REF(H,8)BB>=REF (H,9),REF(H,10),0);
BBB:=TT1+TT2+TT3+TT4+TT5+TT6+TT7+TT8+TT9+TT10;
D:=VALUEWHEN(BBB>0,BBB);
UD:=IF(CLOSE>DREF(CLOSE,1)=C,-3,0));
K:=VALUEWHEN(UD0,UD);
G:=IF(K=1,C,D);
CROSS(CLOSE,REF(G,1)),BPK;
CROSS(REF(G,1),CLOSE),SPK;
而效果测试中可选择的测试价位都是当前周期的各个价位,二者的成交价差差距会比较大。(解决方法:将交易模型中的买卖条件判断数值均替换为上一周期的数值REF(A,1))
胶5分钟期货交易模型{有文华未知函数}
JJ:=DMA(((((((((HIGH + LOW) + REF(HIGH,1)) + REF(LOW,1)) + REF(HIGH,2)) +
REF(LOW,2)) + REF(CLOSE,1)) + CLOSE) / 8),((VOL * 240) / OPENINT));
JJ1:=EMA(JJ,7);
MJ:=(((2 * (((((((HIGH + LOW) + REF(HIGH,1)) + REF(LOW,1)) + REF(HIGH,2)) +
REF(LOW,2)) + REF(CLOSE,1)) + CLOSE)) / 8) - JJ1);
MJ2:=FORCAST(((2 * EMA(MJ,45)) - EMA(EMA(EMA(MJ,45),45),45)),43);
MJ3:=FORCAST(MJ2,145);
MJ31:=EMA(EMA(EMA(MJ3,105),105),105);
EXITLONG:CROSS(MJ31,JJ1);
ENTERLONG:CROSS(JJ1,MJ31);
{MJ未知}
pp:=ma(close,26);
E:=BETWEEN(ABS(CLOSE-MJ),0,10.5)TIME=1458;
B2:=EVERY(CLOSE>PP,10)CLOSE-OPEN>3.5;
S2:=(EVERY(CLOSE3.5)||(REF(OPEN,1)-CLOSE>8.8CLOSEPP);
B3:=CROSS(CLOSE,PP)CLOSE-OPEN>3.5TIME>0906TIME3.5TIME>0906TIME1.2;
(B2||B3)F,BK;
(S2||S3)F,SK;
((B2||B3)F)||E,BP;
((S2||S3)F)||E,SP;
当diff下穿dea,并且价格向下突破ema15日线,就卖平同时等价等量卖开指令,
当diff上穿dea,并且价格向上突破ema15日线,就买平同时等价等量买开指令:
DIFF := EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA:= EMA(DIFF,M);
EMA15:=EMA(CLOSE,15);
DIFF>DEACLOSE>EMA15,BPK;
DEA>DIFFEMA15>CLOSE,SPK;
这样才比较靠谱:
DIFF := EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA:= EMA(DIFF,M);
EMA15:=EMA(CLOSE,15);
CROSS(DIFF,DEA)CLOSE>EMA15,BPK;
CROSS(DEA,DIFF)EMA15>CLOSE,SPK;
HH:=HHV(HIGH,N);
LL:=LLV(LOW,N);
HH1:=BARSLAST((HH > REF(HH,1)));
LL1:=BARSLAST((LL 100,VAR9-100,0);
VARA:=HHV(HIGH,30);
B:=EMA((VAR6-VAR8)/(VARA-VAR8)*100,8),COLORCYAN;
B1:=EMA(B,5);
B-B1>0,BPK;
B-B1SARLINE,BPK;
CLOSEL3,BPK;
L2MA60CROSS(MA5,MA20)||CLOSEMA60CROSS(MA20,MA5)TIMEMA60CROSS(MA20,MA5)TIME=1455,BP;
CLOSEMA60CROSS(MA5,MA20)||CLOSEMA60CROSS(MA20,MA5)TIMEMA60TIME=1455,BP;
CLOSEREF(DATE,1),HIGH);
CLOSE>HTIME>=0930,BK;
CLOSE>H||TIME>=1430,BP;
CLOSE=0930,SK;
CLOSE=1430,SP;
{漂渺峰沪胶15分钟模型}
[N,1.000000,5.000000,1.000000]
[M,1.000000,20.000000,14.000000]
[B,1.000000,5.000000,2.000000]
A:=EMA(CLOSE,N);
AA:=A-REF(A,M);
BB:=SMA(AA,B,2);
BB>0,BPK;
BBAMAHIGH,BK;
CLOSEAMACLOSE,BP;