止损code为:
if holding>0 and enterbars >0 and cross(enterprice-longstop,l) then
begin
sell(holding>0,0,stopr,enterprice-longstop),orderqueue;
kaicang := false;
end
if holding<0 and enterbars>0 and cross(h,enterprice+shortstop) then
begin
sellshort(holding < 0, 0, stopr,enterprice+shortstop),orderqueue;
kaicang := false;
end
以橡胶连续为例,longstop,shortstop为250,即一手一单最大损失应该为2500元左右.
在跑历史数据测试时,发现有些损失远大于2500:
时间 名称 类型 交易价/成本价 交易量 收益(不计平仓费用) 幅度% 资产 最大回撤%
2010/11/19 15:00:00 橡胶连续 平空 34415/32822 1 -15,932.81 -4.85 213,443.94 16.80
2010/11/16 15:00:00 橡胶连续 平多 33520/34948 1 -14,284.96 -4.09 237,975.44 16.80
2011/02/28 15:00:00 橡胶连续 平空 39315/38501 1 -8,138.52 -2.11 216,639.63 28.43
2011/02/16 15:00:00 橡胶连续 平空 41850/41066 1 -7,841.05 -1.91 193,989.13 28.43
2011/03/29 11:30:00 橡胶连续 平空 34490/33757 1 -7,333.75 -2.17 227,162.19 28.43
2010/10/28 14:00:00 橡胶连续 平空 32250/31577 1 -6,731.58 -2.13 243,928.81 16.80
2010/11/17 13:45:00 橡胶连续 平多 32545/33183 1 -6,383.16 -1.92 231,592.25 16.80
2010/08/05 15:00:00 橡胶连续 平多 24440/25043 1 -6,025.04 -2.41 249,709.52 16.80
2010/01/07 10:15:00 橡胶连续 平多 25080/25673 1 -5,925.66 -2.31 185,733.58 12.09
2010/10/25 15:00:00 橡胶连续 平空 32955/32432 1 -5,232.44 -1.61 244,023.44 16.80
2010/12/20 15:00:00 橡胶连续 平空 37320/36846 1 -4,736.84 -1.29 201,612.00 23.05
请教不能及时止损的原因是?
好像只能设百分比啊
这只能等k线走完吧,我用15分钟k线,走完可能差别很大啊
这只能等k线走完吧,我用15分钟k线,走完可能差别很大啊
k线走完取决于你图表交易的设置,和代码关系不大
k线走完取决于你图表交易的设置,和代码关系不大
用c好像好一点,但是用l,h为什么有问题呢?理论上应该一样啊