这样写能实现发单5秒钟后不成交,马上撤单吗?
这样写,能实现发单后,5秒钟不成交,马上撤单吗?运行是不行的,print,tmpOrderbuy.localDateTime,是0,并没有时间。问题出在哪里?
这样写,能实现发单后,5秒钟不成交,马上撤单吗?运行是不行的,print,tmpOrderbuy.localDateTime,是0,并没有时间。问题出在哪里?
ParamsVars global numeric big_con; array<integer>ids; Global integer timer_1; Global numeric buy_ord; Global numeric mybuy_ordprice; Order tmporderbuy; Events OnInit()//---------------------------------------------------------------------------------------------------------- { big_con=0; timer_1=CreateTimer(500); } OnOrder(OrderRef ord)//----------------------------------------------------------------------------------------------- { if(ord.orderid==buy_ord and ord.status==Enum_Declare) { mybuy_ordprice=ord.price; tmporderbuy=ord; } } OnTimer(Integer id,Integer Millsecs)//--------------------------------------------------------------------------------- { if(id==timer_1) { get order print2quote(\"输出\",tmpOrderbuy.localDateTime,\"卖单报单时间\"); print(\"tmpOrderbuy.localDateTime=\"+text(tmpOrderbuy.localDateTime)); if(big_con==1) { if(TimeDiff(tmpOrderbuy.localDateTime,SystemDateTime)>5) { A_DeleteOrderEx(buy_ord); big_con=11; } } } } OnBar(ArrayRef<Integer> indexs) { if(barstatus==2 and big_con==0)//开仓 { if(h-c[1]>=3) { A_SendOrderEx(Symbol,enum_buy,enum_entry,1,c[1]+2,ids); buy_ord=ids[0]; big_con=1; } } }
回复:Order tmporderbuy,是不是也应该定义为Global ,这样在ontime里就能访问到tmporderbuy的属性值了。