文华期货T8软件量化交易模型源码:
多:
//定义变量
MA3:MA(C,3),RGB(255,255,255);
MA20:MA(C,20),RGB(0,0,255);
MA100:MA(C,100),RGB(0,0,255);
DIFF := EMA(CLOSE,12) – EMA(CLOSE,26);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA := EMA(DIFF,9);//DIFF的M个周期指数平滑移动平均
MACD:=2*(DIFF-DEA),PRECIS4,COLORSTICK;//DIFF减DEA的2倍画柱状线
STICKLINE1(MA20>MA100,9,12,4,0),RGB(255,0,0);
STICKLINE1(MA20<MA100,9,12,4,0),RGB(0,255,255);
STICKLINE1(DIFF>0,0,3,4,0),RGB(255,0,0);
STICKLINE1(DIFF<0,0,3,4,0),RGB(0,255,255);
DRAWCOLORLINE(DIFF>0,MA20,RGB(255,0,0),COLORCYAN),LINETHICK3;
DRAWCOLORLINE(MA100>REF(MA100,1),MA100,RGB(255,0,0),RGB(0,255,255));
//做多策略
CROSS(MA20>MA100&&DIFF>0,0.5),BK;
CROSSDOWN(DIFF,0),SP;
//设置
CHECKSIG(BK,’A’,0,’D’,0,0);
CHECKSIG(SP,’A’,0,’D’,0,0);
AUTOFILTER;
空:
//定义变量
MA3:MA(C,3),RGB(255,255,255);
MA20:MA(C,20),RGB(0,0,255);
MA100:MA(C,100),RGB(0,0,255);
DIFF := EMA(CLOSE,12) – EMA(CLOSE,26);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA := EMA(DIFF,9);//DIFF的M个周期指数平滑移动平均
MACD:=2*(DIFF-DEA),PRECIS4,COLORSTICK;//DIFF减DEA的2倍画柱状线
STICKLINE1(MA20>MA100,9,12,4,0),RGB(255,0,0);
STICKLINE1(MA20<MA100,9,12,4,0),RGB(0,255,255);
STICKLINE1(DIFF>0,0,3,4,0),RGB(255,0,0);
STICKLINE1(DIFF<0,0,3,4,0),RGB(0,255,255);
DRAWCOLORLINE(DIFF>0,MA20,RGB(255,0,0),COLORCYAN),LINETHICK3;
DRAWCOLORLINE(MA100>REF(MA100,1),MA100,RGB(255,0,0),RGB(0,255,255));
//做空策略
CROSS(MA20<MA100&&DIFF<0,0.5),SK;
CROSS(DIFF,0),BP;
//设置
CHECKSIG(BK,’A’,0,’D’,0,0);
CHECKSIG(SP,’A’,0,’D’,0,0);
AUTOFILTER;