威廉指標(Williams %R)或簡稱W%R,是一種在1973年就被發明出來的指標,直到現在還是有很多人使用,非常經典;指標的邏輯是用最新的價格,對照一段時間的高低點判斷現在行情偏多或偏空。
H = 一段時間內的最高點
L = 一段時間內的最低點
C = 最新價格
W%R = ( H - C ) / ( H - L ) *100
策略基本設定:
策略名稱 | W%R波段策略 |
交易層級 | 60min |
交易成本 | 來回600 |
回測期間 | 2001-2019/2 |
程式碼:
Input :
len(30),L_in(35),L_out(75) ;
Var :
WR(0) ;
if Highest(h,len)-Lowest(l,len)>0 then
WR = (Highest(h,len)-c) / (Highest(h,len)-Lowest(l,len)) *100 ;
if marketposition<=0 and WR<L_in then
buy 1 share at next bar market ;
if WR>L_out then
sell all shares at next bar market ;
if dayofmonth(date)>14 and dayofmonth(date)<22 and dayofweek(date)=3 then
setexitonclose ;
邏輯中文翻譯:
當WR<35,多單進場 |
當WR>75,多單回補 |
結算出場 |
回測績效檢視:
歷年損益分析: