軟件自帶有海龜系統(tǒng),不過那個(gè)寫的太復(fù)雜不利于理解。后來去理思路的時(shí)候發(fā)現(xiàn)其實(shí)原本海龜設(shè)計(jì)沒有很高深,關(guān)鍵就是在數(shù)量倉位上利用波動(dòng)幅度atr來進(jìn)行構(gòu)建。
出入場(chǎng)條件就根據(jù)唐奇安通道的高低位,屬于典型的趨勢(shì)跟蹤策略,在期貨上前幾年收益還是很驚人的,不過近幾年就不甚理想。
我這里給出一個(gè)我自己整理邏輯后的模板范例
?
TRR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//真實(shí)波幅
ATR:=ref(MA(TRR,20),1); //波幅的20日均線
unit:(asset*0.01)/(MULTIPLIER*atr);
INPUT:X(20,1,100,5);
X周期高點(diǎn):=REF(HHV(H,X),1);//X是參數(shù),自行調(diào)整
X周期低點(diǎn):=REF(LLV(L,X),1);
//記錄建倉的atr
variable:entry=0;
//記錄交易次數(shù)
variable:num=0;
//入場(chǎng)條件:
開多條件:=High>=X周期高點(diǎn) and barpos>20;
開空條件:=Low<=X周期低點(diǎn) 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個(gè)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)計(jì)出場(chǎng)和止損的次數(shù)
variable:n1=0,n2=0;
//止損2個(gè)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
//破短期高低位,平倉出場(chǎng)
INPUT:Y(10,1,100,5);
Y周期高點(diǎn):=REF(HHV(H,10),1);
Y周期低點(diǎn):=REF(LLV(L,10),1);
if low<Y周期低點(diǎn) and holding>0 then
begin
?sell(1,holding,marketr);
?n2:=n2+1;
end
if high>Y周期高點(diǎn) and holding<0 then
begin
?sellshort(1,holding,marketr);
?n2:=n2+1;
end
?
{別忘了將本網(wǎng)告訴您身邊的朋友,向朋友傳達(dá)有用資料,也是一種人情,你朋友會(huì)感謝你的。}
?