全部 智大领峰 TBQuant功能 TBL语言 TB开户 问答专区 高手圈 其他
这样写能实现发单5秒钟后不成交,马上撤单吗?
zg520_3 分享到
2023-04-25 11:57

data-href=

data-href=

这样写,能实现发单后,5秒钟不成交,马上撤单吗?

运行是不行的,print,tmpOrderbuy.localDateTime,是0,并没有时间。问题出在哪里?

zg520_3

Params

Vars

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;

}

}

}

2023-04-25 12:37
yfhyb9
@zg520_3

Order tmporderbuy,是不是也应该定义为Global ,这样在ontime里就能访问到tmporderbuy的属性值了。

2023-06-08 15:57
您未登录,请先 登录注册 后发表评论
顶部