-- 作者:zqs0595
-- 发布时间:2016/9/21 11:34:33
--
//捕获快速下跌和快速上涨的行情 runmode:0;
zh:=\'613938\'; //交易账号
//日志文件路径 logFilePath:=\'D:\\jztLog\\log.txt\'; DEBUGFILE2(logFilePath,\'******begin1******\',1,1);
input:changeSecond(10,10,200,20); //多少秒上涨或下跌一定幅度,大时间周期确定趋势并入场 input:outSecond(20,10,120,20); //当前价与N秒的移动平均线交叉,止损出局 input:changeRate(0.01,0.01,2,0.2); //secondNum秒内的涨跌幅度百分之0.2 cs:=NUMTOSTR(changeSecond,0); //数字转字符,方便调用 mn:=NUMTOSTR(outSecond,0); //数字转字符,方便调用
lastClose:=ref(c,1); //上一秒K线收盘价 orderNum:=1; //下单数量 entertime:=(time>=010300 and time<=025500) or (time>=130300 and time<=185500); //下单时间 exittime:=(time>025500 and time<=120000) or (time>185500 and time<=230000); //清仓离场时间 //lostTooMuch:=(ref(asset,todaybar)-asset)/ref(asset,todaybar)>0.1; //今日亏损超10% deadplus:=CROSS(STKINDI(\'\',\'getSecondMa.ma1(\'&mn&\')\',0,22,1),lastClose); //离场死叉 goldplus:=CROSS(lastClose,STKINDI(\'\',\'getSecondMa.ma1(\'&mn&\')\',0,22,1)); //离场金叉
//持有多头仓位时,如果当前价和秒均线死叉,平掉多头仓位 if tholding>0 and (deadplus or exittime) then begin TSELL(1,tholding,mkt,zh); DEBUGFILE2(logFilePath,\'>最新价与秒均线死叉或者将到\',1,1); DEBUGFILE2(logFilePath,\'>收盘时间,平掉多头仓位\',1,1); end
//持有空头仓位时,如果当前价和秒均线金叉,平掉空头仓位 if tholding<0 and (goldplus or exittime) then begin TSELLSHORT(1,tholding,mkt,zh); DEBUGFILE2(logFilePath,\'>最新价与秒均线金叉或者将到\',1,1); DEBUGFILE2(logFilePath,\'>收盘时间,平掉空头仓位\',1,1); end
//空仓时,判断是否有下单机会 if tholding=0 then begin //取cs秒内的最大值和最小值 shigh:=STKINDI(\'\',\'getSecondHHV.c1(\'&cs&\')\',0,22,1); slow:=STKINDI(\'\',\'getSecondLLV.c1(\'&cs&\')\',0,22,1);
DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'shigh = %.2f\',shigh,1); DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'slow = %.2f\',slow,1); DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'lastClose = %.2f\',lastClose,1); //changeSecond秒内跌幅超指定幅度,做空 and lostTooMuch=0 if ROUNDS((shigh - lastClose)/shigh,2)>changeRate and entertime then begin MSGOUT(1,\'做空\'); TBUYSHORT(1,orderNum,mkt,zh); DEBUGFILE2(logFilePath,\'>满足开空条件,建仓空头\',1,1); end //changeSecond秒内涨幅超指定幅度,做多 and lostTooMuch=0 if ROUNDS((lastClose - slow)/slow,2)>changeRate and entertime then begin MSGOUT(1,\'做多\'); TBUY(1,orderNum,mkt,zh); DEBUGFILE2(logFilePath,\'>满足开多条件,建仓多头\',1,1); end end
DEBUGFILE2(logFilePath,\'******end******\',1,1);
|