軟件自帶有海龜系統(tǒng),不過那個寫的太復雜不利于理解。后來去理思路的時候發(fā)現其實原本海龜設計沒有很高深,關鍵就是在數量倉位上利用波動幅度atr來進行構建。
出入場條件就根據唐奇安通道的高低位,屬于典型的趨勢跟蹤策略,在期貨上前幾年收益還是很驚人的,不過近幾年就不甚理想。
我這里給出一個我自己整理邏輯后的模板范例
?
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
//統(tǒng)計出場和止損的次數
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
?
{別忘了將本網告訴您身邊的朋友,向朋友傳達有用資料,也是一種人情,你朋友會感謝你的。}
?