EasyTrader ArtNo 148
我們常在文獻/期刊/網路上看到很多國外不錯的策略 ,在轉化吸收的過程會碰到以下問題最近在策略開發進階班課程裡會介紹一個隨機參數的方法,應用它會讓我們在參數測試上節省不少時間,在這裡我引用Wen大介紹的一篇利用VIX 交易 S&P 100 INDEX(^OEX) 的程式碼作測試
在加入結算日後 ,我先將其中數字部份全部轉換為參數,多空各五個參數 ,然後利用隨機參數的方式同時對10個參數作測試,在很短的時間內作出以下的結果
台股 VIX資料為2007開始 ,以下測試為台指期 日K 留倉 , 2007~ 2014/4/30 交易成本 1200
input:AvgBarL(47),LookBackL1(15),BollLengthL(10),StdDev_L(0.65),NBarL(16),
AvgBarS(27),LookBackS1(16),BollLengthS(23),StdDev_S(1.1),NBarS(8) ;
Vars: LastTradeDay(false) ;
if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then LastTradeDay = True else LastTradeDay =False ;
If Close of Data1 > Average(Close of Data1, AvgBarL) and (Close[LookBackL1] of Data2) <
BollingerBand(Close of Data2, BollLengthL, StdDev_L)[LookBackL1]
and Close[LookBackL1+1] of Data2 > BollingerBand(Close of Data2, BollLengthL, StdDev_L)[LookBackL1+1] Then Buy on Close of Data1 Stop;
input:AvgBarL(47),LookBackL1(15),BollLengthL(10),StdDev_L(0.65),NBarL(16),
AvgBarS(27),LookBackS1(16),BollLengthS(23),StdDev_S(1.1),NBarS(8) ;
Vars: LastTradeDay(false) ;
if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then LastTradeDay = True else LastTradeDay =False ;
If Close of Data1 > Average(Close of Data1, AvgBarL) and (Close[LookBackL1] of Data2) <
BollingerBand(Close of Data2, BollLengthL, StdDev_L)[LookBackL1]
and Close[LookBackL1+1] of Data2 > BollingerBand(Close of Data2, BollLengthL, StdDev_L)[LookBackL1+1] Then Buy on Close of Data1 Stop;
If BarsSinceEntry = NBarL and Close of Data1 < Close[NBarL] of Data1 Then
ExitLong on Close of Data1 stop;
If Close of Data1 < Average(Close of Data1, AvgBarS) and (Close[LookBackS1] of Data2) >
BollingerBand(Close of Data2, BollLengthS, -StdDev_S)[LookBackS1]
and Close[LookBackS1+1] of Data2 < BollingerBand(Close of Data2, BollLengthS, -StdDev_S)[LookBackS1+1] Then Sell on Close of Data1 stop;
If BarsSinceEntry = NBarS and Close of Data1 > Close[NBarS] of Data1 Then
ExitShort on Close of Data1 stop;
if LastTradeDay then SetExitOnClose ;
ExitLong on Close of Data1 stop;
If Close of Data1 < Average(Close of Data1, AvgBarS) and (Close[LookBackS1] of Data2) >
BollingerBand(Close of Data2, BollLengthS, -StdDev_S)[LookBackS1]
and Close[LookBackS1+1] of Data2 < BollingerBand(Close of Data2, BollLengthS, -StdDev_S)[LookBackS1+1] Then Sell on Close of Data1 stop;
If BarsSinceEntry = NBarS and Close of Data1 > Close[NBarS] of Data1 Then
ExitShort on Close of Data1 stop;
if LastTradeDay then SetExitOnClose ;
0 留言:
張貼留言
如果有私人問題想請教,請透過網站右方『與站長聯絡』之表單,謝謝!