文华财经T8跨周期均线排列自动交易量化策略模型源码:
5分钟交易策略模型:
TR : =MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : =MA(TR,26);
H1:VALUEWHEN(DAYBARPOS=2,HHV(H,DAYBARPOS));
L1:VALUEWHEN(DAYBARPOS=2,LLV(L,DAYBARPOS));
DAYBARPOS>1&&(H1-L1)/L1<0.01&&C>H1&&V>MA(V,5)&&(COUNTSIG(BK,DAYBARPOS)+COUNTSIG(SK,DAYBARPOS))=0,BK;
(C<L1||C<H1-1*ATR)&&BKVOL>0,CLOSEOUT;
DAYBARPOS>1&&(H1-L1)/L1<0.01&&C<L1&&V>MA(V,5)&&(COUNTSIG(BK,DAYBARPOS)+COUNTSIG(SK,DAYBARPOS))=0,SK;
(C>H1||C>L1+1*ATR)&&SKVOL>0,CLOSEOUT;
CLOSEMINUTE<=2,CLOSEOUT;
AUTOFILTER;
增加跨周期条件:(在原来基础上进行数据跨周期引用)
5分钟策略的基础上加上日线呈多头排列时,符合5分钟做多条件开多仓,反之,日线呈空头排列,符合5分钟做空条件,方开空仓。
模型源码:(分别建立两个模型)
MA5:MA(C,5);
MA10:MA(C,10);
MA30:MA(C,30);
AA:=MA5>MA10&&MA10>MA30;
BB:=MA5<MA10&&MA10<MA30;
#IMPORT[DAY,1,AA] AS VAR1
AA:=VAR1.AA;
BB:=VAR1.BB;
TR : =MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : =MA(TR,26);
H1:VALUEWHEN(DAYBARPOS=2,HHV(H,DAYBARPOS));
L1:VALUEWHEN(DAYBARPOS=2,LLV(L,DAYBARPOS));
AA&&DAYBARPOS>1&&(H1-L1)/L1<0.01&&C>H1&&V>MA(V,5)&&(COUNTSIG(BK,DAYBARPOS)+COUNTSIG(SK,DAYBARPOS))=0,BK;
(C<L1||C<H1-1*ATR)&&BKVOL>0,CLOSEOUT;
BB&&DAYBARPOS>1&&(H1-L1)/L1<0.01&&C<L1&&V>MA(V,5)&&(COUNTSIG(BK,DAYBARPOS)+COUNTSIG(SK,DAYBARPOS))=0,SK;
(C>H1||C>L1+1*ATR)&&SKVOL>0,CLOSEOUT;
CLOSEMINUTE<=2,CLOSEOUT;
AUTOFILTER;