请教定时器问题

感恩各位大佬莅临指导:(1)设计思路:每天收盘前2分钟如果有持仓就全部平仓。以午盘11:30为例,也就是11:28开始平所有持仓。(2)问题:运行程序后,结果定时器立刻运行,且ontimer立刻就开始运行平仓了。定时器的起始时间是否设置有误?或者如何表示每天的某个时间呢?代码如下:Params //此处添加参数 Vars //此处添加变量 //Global order myorder; Global Position mypositon; Global Array<Integer> timeArr; Integer i; Defs //此处添加策略函数 Events //此处实现事件函数 //初始化事件函数,策略运行期间,首先运行且只有一次 OnInit() { timeArr[0] = CreateTimer(1000,0.1128,5);//是否有误。 } OnReady() { //根据操作源ID订阅委托 Bool ret = A_SubscribeTradeByCreateId(Enum_Trade_Source_ALL); Print("A_SubscribeTradeByCreateId:" + IIFString(ret, "True", "False")); } //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { Bool ret = A_GetPosition(mypositon,"",0); //print("---------------holding--------------"); //print("longCurrentVolume:"+text(mypositon.longCurrentVolume)); //print("shortCurrentVolume:"+text(mypositon.shortCurrentVolume)); //print("---------------holdings--------------"); //print("timeArr:"+text(GetArraySize(timeArr))); } OnTimer(Integer Id, Integer millSecs) { Integer a = GetArraySize(timeArr); for i = 0 to a-1 { if(id == timeArr[i]) { if(mypositon.longCurrentVolume != 0) { A_SendOrder(Enum_sell, Enum_Exit, mypositon.longCurrentVolume, close - 50 * MinMove * PriceScale); print("-------longclear------"); }; if(mypositon.shortCurrentVolume != 0) { A_SendOrder(Enum_buy, Enum_Exit, mypositon.shortCurrentVolume, close + 50 * MinMove * PriceScale); print("-------shortclear------"); }; } } }

CreateTimer(1000,0.1128,5);额,这个0.1128应该指的是1970年1月1日11点28分你如果是想当天的11点28分,应该把日期也加上

回复:收到,谢谢刘总