我用的是日线,我想在回测中实现。若买入价为N,则次日起日线内只要有低于N-2%的价格,均被止损卖出。请教这个怎么写?[/br]
我写的是:[/br]
if enterbars>=1 and low<=enterprice*(98/100)[/br]
then sell(holding>0,100%,stop,enterprice*(98/100));//买入后次日起盘中触止损底线-2%卖出[/br]
if enterbars>=1 and o/enterprice<=(98/100)[/br]
then sell(holding>0,100%,stop,o);//买入后次日起若开盘价就低于止损价-2%则开盘卖出[/br]
上述公式在图表回测中有问题,有时正常有时不正常,不正常的表现为理应卖出日有灰白箭头标示,次日在理应平仓位有灰白色小三角,但却没有真正的绿色“平多”箭头和标示平仓的绿色小三角出现。
请教该如何修改 ?
[此贴子已经被作者于2011-9-6 17:44:14编辑过]
有白色箭头表示你委托的价格超过了交易K线的高低价了,委托失败。
if enterbars>=1 and holding>0 and L<enterprice*0.98 then sell(1,1,limitr,min(o,enterprice*0.98)-mindiff);