策略靈感來源從以下這個影片來的,可以先看看
看完後,有點好奇績效是不是真的那麼厲害,嘗試改成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;

![[VIP] XQ版RS相對強弱PR指標](https://aplus.trading/wp-content/uploads/2024/11/a-captivating-illustration-of-the-relative-strengt-t0oo_72pQ6-5mpJuqSoDQ-h1cSwJr9Qv-Gwfy41ebhgw-870x570.jpeg)
![[VIP]用彼得林區邏輯 + XQ 選股中心打造成長型策略](https://aplus.trading/wp-content/uploads/2025/07/a-captivating-modern-digital-illustratio_7OaYIF8kT4aUUDGs6AJjBw_tLDjMWjvSXWPG5ycIUliAg-870x570.jpeg)



![[VIP] 短線策略8-月營收創高策略](https://aplus.trading/wp-content/uploads/2025/11/cover-150x150.jpg)
![[VIP] 短線策略7-買賣家數集中度策略](https://aplus.trading/wp-content/uploads/2025/10/a-digital-illustration-of-a-stock-chart-_xtRnCKHdQnK_7iicsxxCHA_l-Cu3wWZQSapjzKMZmrLnw-150x150.jpeg)

第41,42行不論多空的判斷條件都是_nvi>avNVI,似乎不太對?
請問影片連結還有嗎?
已修正
不用理會前一篇找影片連結的留言, 有找到了
但丟進回測, 一樣的條件跑出來的結果天差地遠, 包括VIP的也是, 不知道問題出在哪
策略開發出來,本就無法保證未來績效,這篇文章是2022/02寫的,後來的確表現沒那麼好,您的回測應該是最近幾年,所以回測結果一定跟上面不同,如遇到後期表現不佳,可以嘗試再優化看看,不過這個策略近期似乎又要創高了,可以再觀察看看
另外,建議是測試下面的VIP策略,表現的是比較好的,202305寫的,一直到202410都在創高,最近沒創高,但也沒啥回檔
https://aplus.trading/原創-這簡單也行pvi均線黃金交叉策略-vip/