各位论坛里的老师,我发现软件自带的双向海龟交易系统在做策略测试时成功率较低,尤其是开多或开空加仓的第4次(手)时。可不可以修改一下,将原来的开多改为开空、开空改为开多,并设置恰当的止损空间,在较短周期高频交易中测试一下,应该成功率较高。另外,软件原来的海龟交易系统公式太复杂,我们初学者难弄懂,论坛里有位老师发了一个改动的,但开仓量太大,能否专门设一个可调节变量。谢谢!
TRR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//真实波幅
ATR:=ref(MA(TRR,20),1); //波幅的20日均线
unit:(asset*0.01)/(MULTIPLIER*atr); INPUT:X(20,1,100,5);
X周期高点:=REF(HHV(H,X),1);//X是参数,自行调整
X周期低点:=REF(LLV(L,X),1); //记录建仓的atr
variable:entry=0;
//记录交易次数
variable:num=0;
//入场条件:
开多条件:=High>=X周期高点 and barpos>20;
开空条件:=Low<=X周期低点 and barpos>20; //建立头寸
if 开多条件 and holding=0 then
begin
buy(1,unit,marketr);
entry:=atr;
num:=1;
end if 开空条件 and holding=0 then
begin
buyshort(1,unit,marketr);
entry:=atr;
num:=1;
end
//每盈利0.5个atr加仓,最多加4次
if holding>0 and high>enterprice+0.5*entry and num<4 then
begin
buy(1,unit,marketr);
num:=num+1;
end
if holding<0 and low<enterprice-0.5*entry and num<4 then
begin
buyshort(1,unit,marketr);
num:=num+1;
end //统计出场和止损的次数
variable:n1=0,n2=0; //止损2个atr
if holding>0 and low<enterprice-2*entry and holding>0 then
begin
sell(1,holding,marketr);
n1:=n1+1;
end
if holding<0 and high>enterprice+2*entry and holding<0 then
begin
sellshort(1,holding,marketr);
n1:=n1+1;
end //破短期高低位,平仓出场
INPUT:Y(10,1,100,5);
Y周期高点:=REF(HHV(H,10),1);
Y周期低点:=REF(LLV(L,10),1);
if low<Y周期低点 and holding>0 then
begin
sell(1,holding,marketr);
n2:=n2+1;
end
if high>Y周期高点 and holding<0 then
begin
sellshort(1,holding,marketr);
n2:=n2+1;
end
|