《Wen外期策略團隊》
簡單利用快慢兩個不同的布林通道分別控制進出場的簡單系統,以下是台指期的測試,供讀者練習。
回測設定:
●商品:TXF@60K(修正換月價差的歷史資料)
●手續費設定:單邊500元 (來回1000元)
●回測時間:2003/1/21~2014/10/13
●其他:只測試多單。
指標:(白色是慢布林進場點,黃色為快布林出場點)文章程式碼參考Active trader網站
Code:
vars:SlowerLB(0),FasterLB(0),LongBase(0),ShortBase(0),LongRisk(0),ShortRisk(0);
//For the Bollinger-band system (group A):
SlowerLB = 18; //(36, 72)
FasterLB = 12; //(24, 48)
LongBase = Average(Close, SlowerLB) + StdDev(Close, SlowerLB) * 2.2;
ShortBase = Average(Close, SlowerLB) - StdDev(Close, SlowerLB) * 2.2;
LongRisk = LongBase - Average(Close, FasterLB);
ShortRisk = Average(Close, FasterLB) - ShortBase;
//For the Donchian systems (group B):
{
SlowerLB = 18; //(36, 72)
FasterLB = 12; //(24, 48)
LongBase = Highest(High, SlowerLB);
ShortBase = Lowest(Low, SlowerLB);
LongRisk = LongBase - 0.5 * (Highest(High, FasterLB) + Lowest(Low, FasterLB));
ShortRisk = 0.5 * (Highest(High, FasterLB) + Lowest(Low, FasterLB)) - ShortBase;
}
//Shared code:
vars:EntryLevel(0),ExitLevel(0);
If EntriesToday(date) < +1 Then begin
EntryLevel = LongBase;
ExitLevel = LongBase - LongRisk;
end
Else begin
EntryLevel = EntryLevel[1];
ExitLevel = maxlist(LongBase - LongRisk, ExitLevel[1]);
end;
If marketposition=0 then begin
buy next bar at EntryLevel stop;
// sellshort next bar at Entrylevel stop;
end;
If marketposition=1 then begin
sell next bar at ExitLevel stop;
end;
回測結果:
0 留言:
張貼留言
如果有私人問題想請教,請透過網站右方『與站長聯絡』之表單,謝謝!