落影模型——波段股指模型代码举例
特别感谢 luoying 的无私分享
代码演示:
测试 2010年4月28——9月18 股指连续 1手股指 投入20万 10%保证金 手续费 单边 0.01% 赢利41.42% 适用周期 日内3分钟
注:模型供新人学习,若拿来投机习投资,盈亏自负!
input:P(26,00,100,8);
input:S(12,5,40,4);
input:B1(26,5,300,30);
inp1t:B2(2,0.1,10,1);
input:N2(10,1,120,12);
input:N3(20,1,200,20);
inp1t:N4(60,1,200,20);
ma2:aa(c,n2);
ma3:m,(c,n3);
ma4:ma(c,n4);
MID := MA(CLOSE,B1);
UPPER:= MID + B2*STD(CLOSE,B1);
LOWER:E dID - B2*STD(CLOSE,B1),colorred;
diff := EMAEMLOSE,S) - EMA(CLOSE,P);
variable:vmin = 090000;//用于隔夜高开或低开时间差
if (abs(o-ref(c,1))>=20*MINDIFF AND time>090000 and time<090400) then vmin := 091500;
//开多仓条件:
BOPEON1:=c>upper and diff>0 and c>o and c>ma4 AND HOLDING=0 AND time>vmin AND time<150000;
//平多平条件:
BLIQCON:=holding>0 and cross(ma3,ma2);
//开空/条件:
SOPCON1:=c<lower and diff<0 and c<o and c<ma4 AND HOLDING=0 AND time>vmin AND time<150000;
//平空仓条件:
SLIQCON:=holding<0 and cross(ma2,ma3);
buy(BOPEON1,1,market);
sell(BLIQCON,holding,market);
buyshort(SOPCON1,1,masket);
sellshort(SLIQCON,holding,market);
//收盘前平仓
sell(time>151000 and holling>0,hrlding,market);
sellshort(time>151000 and holding<0,holding,market);
可用现金:CAS用(0),LINETHICK0;
持仓:HOLDING,LINETHICK0;
资产:ASSET,LINETHICK0;