策略靈感來源從以下這個影片來的,可以先看看
看完後,有點好奇績效是不是真的那麼厲害,嘗試改成XQ的交易程式碼,跑出來的績效似乎還不錯,2016/09到2021/10,獲利接近160萬,最驚人的是勝率竟然高達81.08%,整個權益曲線也算是一路向上,仔細的看了下,最大虧損交易竟然是-31萬,最大區間虧損也高達-62萬,嗯,這應該不是普通人能用的策略~~
既然上面的結果不是普通人能用的,那就只好繼續來改造下,看能否搞出個普通人能用的策略,運氣還不錯,同樣回測區間,也能獲利136萬,雖然勝率變低,但最大虧損跟最大區間虧損,大幅降低至5.8萬跟13萬,且權益曲線是一路往上,每年都是獲利的,已經算是不錯的策略了
回測設定如下,有興趣的可以調整參數或是增加其他進出場條件,應該能找到更加的組合。
檔案下載

程式碼如下
//https://www.youtube.com/watch?v=TpR7Cdy7pko //v3 增加出場濾網,不然MDD太大 input: lostex(150,"虧損多少點出場"); input: PVIlen(15),NVIlen(40),bk1(3),bk2(12); vars: avPVI(0), avNVI(0); vars: trendbull(false),trendbear(false); vars: intrabarPersist entryonce(0); Variable: _pvi(1),_nvi(1); if date<>date[1] then entryonce=0; If CurrentBar = 1 then _pvi = 100 else begin if Volume > Volume[1] then _pvi = _pvi[1] + ((Close - Close[1]) / Close[1])*_pvi[1] else _pvi = _pvi[1]; end; avPVI=average(_pvi,PVIlen); If CurrentBar = 1 then _nvi = 100 else begin if Volume < Volume[1] then _nvi = _nvi[1] + ((Close - Close[1]) / Close[1])*_nvi[1] else _nvi = _nvi[1]; end; avNVI=average(_nvi,NVIlen); trendbull=_nvi>avNVI and _pvi<avPVI; trendbear=_nvi>avNVI and _pvi>avPVI; if position<=0 and trendbull and entryonce=0 // and close>average(getfield("close","D")[1],5) 測試用條件 and close>highest(high[1],2) then begin setposition(1,highest(H,bk1)); entryonce=1; end; //if position>=0 and trendbear then //翻單 // setposition(-1,lowest(l,bk2)); if position>=0 and filled=1 and trendbear then begin setposition(0,market); end; if position>=0 and filled=1 and close<filledavgprice-lostex then begin setposition(0,market); end; //-----期貨換月出場 var: b_balanceDay(false); if date<>date[1] then begin b_balanceDay=false; if (dayofmonth(Date)>=15 and DayofMonth(Date)<=21 and DayofWeek(Date)=3) then b_balanceDay=true; end; if b_balanceDay=true and position=1 and filled=1 and time>=130000 then begin setposition(0,close); end;
發佈留言
很抱歉,必須登入網站才能發佈留言。