看了一些收盘前平仓的代码,搞乱了,请老师厘清!
股指期货,我现在要求在151359时无论什么头寸都下单平仓,这个代码应该怎么写?要用交易所时间,不是本地电脑的时间。
下面三种的哪一种?
DYNAINFO(207)>151339 and islastbar
time > 151359 and not(islastbar)
not(islastbar) and time=151500 or islastbar and currenttime>151359
not(islastbar) and time=151500 or islastbar and currenttime>151359
这个,你还是没有理解代码的含义
楼上正解
not(islastbar) and time=151500 //非最后一根K线,时间151500平仓
(islastbar and DYNAINFO(207)>151359)//最后一根K线,151359平仓----取的就是交易所时间
结合起来就是
not(islastbar) and time=151500 or (islastbar and DYNAINFO(207)>151359)
自己检测了一下,上述代码可以评测,不过在1minK线上对照一下信号,发现收盘平仓的信号出现在最后一根K线上,而个人原来的本意是要在倒数第二根K线走完时平仓,这样,于上述代码
not(islastbar) and time=151500就有点出入,可否改成下面这样?not(islastbar) and time=151400 or (islastbar and DYNAINFO(207)>151359);
发现改成这样后,收盘信号就出现在倒数第二根K线上了,请老师指点! |