//修改用于实盘,效果差了点。但必须这样了,用收盘价突破成立信号,用收盘价交易,去隐性未来
//中间变量
INPUT:X(20,1,100,1),NMIN(10,1,100,1),SS(1,1,10000,1);
X周期高点:=REF(HHV(H,X),1);//X是参数,自行调整
X周期低点:=REF(LLV(L,X),1);
手数:=SS;
开仓时间:=TIME>OPENTIME(1) AND TIME<CLOSETIME(0)-NMIN*100;
平仓时间:=TIME>=CLOSETIME(0)-NMIN*100;
{NMIN为参数,CLOSETIME(0)-NMIN*100表示 收盘时间-提前N分钟 N由NMIN控制}
//交易条件:
开多平空条件:=c>=X周期高点 and 开仓时间 and holding<=0;
开空平多条件:=c<=X周期低点 and 开仓时间 and holding>=0;
//交易系统
收盘平多:sell(平仓时间 and holding>0, 0, thisclose);
收盘平空:sellshort(平仓时间 and holding<0,0,thisclose);
平空:sellshort(开多平空条件 and holding<0, 手数,thisclose);
平多:sell(开空平多条件 and holding>0,手数,thisclose);
开空:buyshort(开空平多条件 and holding=0,手数,thisclose);
开多:buy(开多平空条件 and holding=0, 手数,thisclose);
//以下为信号统计结果
持仓:holding,COLORWHITE,linethick0;
资产:asset,COLORMAGENTA,noaxis;
可用现金:cash(0),COLORYELLOW,linethick0;
盈亏:asset-1000000,noaxis,colorred,linethick0;
胜率:PERCENTWIN,colorwhite,linethick0;
交易总数:totaltrade,COLORCYAN,linethick0;
盈次:NUMWINTRADE,colorred,linethick0;
亏次:NUMLOSSTRADE,colorgreen,linethick0;
连盈:NUMSEQWIN,colorred,linethick0;
连亏:NUMSEQLOSS,colorgreen,linethick0;