老师好,请教:在期指1分钟周期里面,用逐K线模式作图表式自动交易,我想在亏损的当根K线未走完时及时进行止损平仓,以避免在极端行情下的秒上(下)带的重大损失,请问代码怎么实现?
老师,这样的话,盘中会有信号闪烁导致的开仓或平仓单---我的只想在止损上实现实时止损,开仓平仓仍按K线走完模式
是否可以继续执行逐K线模式,也不改变策略代码,只在下单设置里面在固定止损上打勾(设置好后)?
勾选固定时间间隔,止盈止损用本周的条件,开平仓条件用上周期条件,ref(开仓条件,1)
这样既可以及时止盈止损,也可以避免开平仓信号闪烁
[此贴子已经被作者于2014/12/30 16:38:42编辑过]
老师,是否是这样调整策略代码:
原来的代码:
if kd then begin
sellshort(1,0,market),orderqueue;
buy(holding=0,1,market),orderqueue;
end
if kk then begin
sell(1,0,market),orderqueue;
buyshort(holding=0,1,market),orderqueue;
end
if pd or (enterprice-c)>=10 then sell(holding>0,0,market);
if pk or (c-enterprice)>=10 then sellshort(holding<0,0,market);
改后的代码:
if ref(kd,1) then begin
sellshort(1,0,limitr,o),orderqueue;
buy(holding=0,1,limitr,o),orderqueue;
end
if ref(kk,1) then begin
sell(1,0,limitr,o),orderqueue;
buyshort(holding=0,1,limitr,o),orderqueue;
end
if ref(pd,1) or (enterprice-c)>=10 then sell(holding>0,0,market),orderqueue;
if ref(pk,1) or (c-enterprice)>=10 then sellshort(holding<0,0,market),orderqueue;
要走完k线就ref,不需要走完k线希望立即下单的,不要加
我的开仓需要走完K线,平仓和止损不要走完K线,上述表达对吗?