程序开头打了个begin,程序结果打了个end.
2016-09-21 10:54:53.508 ******begin******
2016-09-21 10:54:53.508 shigh = 2256.00
2016-09-21 10:54:53.508 slow = 2254.00
2016-09-21 10:54:53.508 lastClose = 2256.00
2016-09-21 10:54:53.508 ******end******
2016-09-21 10:54:53.508 ******begin******
2016-09-21 10:54:53.508 shigh = 2256.00
2016-09-21 10:54:53.508 slow = 2254.00
2016-09-21 10:54:53.508 lastClose = 2255.00
2016-09-21 10:54:53.508 ******end******
2016-09-21 10:54:53.508 ******begin******
2016-09-21 10:54:53.508 shigh = 2256.00
2016-09-21 10:54:53.508 slow = 2254.00
2016-09-21 10:54:53.508 lastClose = 2256.00
2016-09-21 10:54:53.508 ******end******
2016-09-21 10:54:53.508 ******begin******
2016-09-21 10:54:53.508 shigh = 2256.00
2016-09-21 10:54:53.524 slow = 2254.00
2016-09-21 10:54:53.524 lastClose = 2255.00
2016-09-21 10:54:53.524 ******end******
2016-09-21 10:54:53.524 ******begin******
2016-09-21 10:54:53.524 shigh = 2256.00
2016-09-21 10:54:53.524 slow = 2254.00
2016-09-21 10:54:53.524 lastClose = 2255.00
2016-09-21 10:54:53.524 ******end******
2016-09-21 10:54:53.524 ******begin******
2016-09-21 10:54:53.524 shigh = 2256.00
2016-09-21 10:54:53.524 slow = 2254.00
2016-09-21 10:54:53.524 lastClose = 2255.00
2016-09-21 10:54:53.524 ******end******
2016-09-21 10:54:53.524 ******begin******
2016-09-21 10:54:53.524 shigh = 2256.00
2016-09-21 10:54:53.524 slow = 2254.00
2016-09-21 10:54:53.524 lastClose = 2256.00
2016-09-21 10:54:53.524 ******end******
2016-09-21 10:54:53.524 ******begin******
2016-09-21 10:54:53.524 shigh = 2256.00
2016-09-21 10:54:53.524 slow = 2254.00
2016-09-21 10:54:53.524 lastClose = 2255.00
2016-09-21 10:54:53.524 ******end******
请把公式代码也一起贴过来
//捕获快速下跌和快速上涨的行情
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);
不是我的代码问题,我新建了一个空的后台程序化交易系统,代码如下:
//捕获快速下跌和快速上涨的行情
runmode:0;
logFilePath:='D:\jztLog\log.txt';
DEBUGFILE2(logFilePath,'******begin2******',1,1);
DEBUGFILE2(logFilePath,'******end******',1,1);
照样一秒钟执行很多次
看下你后台程序化设置的界面
哪个地方可以看?
ISLASTBAR,在历史上是0,所以不会执行。只有最新的k上值才是1,
另外,你测了在刚加载是,会有一个初始化的过程,对历史上的k线进行一个运算,才会刷新到新的值。
我说的设置,交易----后台程序化中设置的界面,运行周期,运行模式这些。是否勾选不间断监控,这个是我5楼中要的