根据TradingView的描述: Williams%R(%R)是一种基于动量的振荡器,用于技术分析,主要用于识别超买和超卖情况。%R基于当前收盘价与用户定义的回望期内的最高收盘价之间的比较。%R在0和-100之间波动(注意负值),读数接近零表示超买情况更多,读数接近-100表示超卖。通常%R可以根据超买和超卖情况以及动量的整体变化生成设置。
有什么特别的? 该指标在原来的Williams%R指标上增加了两条额外的EMA线。默认EMA长度为5和13。结果是2条更平滑的平均线,更容易阅读。 该指标包括: -EMA交叉信号。均线交叉有助于表明已确认的趋势变化。默认颜色为绿色和红色 -更快的均线上的趋势反转信号。默认颜色为蓝色和橙色
牛市/熊市交叉和反转警报可用。
享受~~!
回测测试
/*backtest start: 2021-12-01 09:00:00 end: 2022-06-05 15:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © platsn //@version=5 indicator(title='Williams %R - Smoothed', shorttitle='The Smooth Willy') // Williams %R length = input.int(defval=34, minval=1, title="周期") upper = ta.highest(length) lower = ta.lowest(length) output = 100 * (close - upper) / (upper - lower) fast_period = input(defval=5, title='Smoothed %R 周期') slow_period = input(defval=13, title='慢线 EMA 周期') fast_ema = ta.wma(output,fast_period) slow_ema = ta.ema(output,slow_period) // Plot //h1 = hline(-20, title='Upper Band') //h2 = hline(-80, title='Lower Band') //fill(h1, h2, title='Background', transp=90) plot(output, title='%R', color=color.new(color.white, 80), linewidth=1) plot(fast_ema, title='Smoothed %R', color=color.new(color.yellow, 0), linewidth=2) plot(slow_ema, title='Slow EMA', color=color.new(color.aqua, 0), linewidth=2) bullX = ta.crossover(fast_ema, slow_ema) bearX = ta.crossunder(fast_ema, slow_ema) bullreverse = fast_ema[2] > fast_ema[1] and fast_ema > fast_ema[1] and fast_ema < -30 bearreverse = fast_ema[2] < fast_ema[1] and fast_ema < fast_ema[1] and fast_ema > -70 plotX = input.bool(true, "显示 EMA 交叉") plotRev = input.bool(true, "显示 趋势 反转") //plotshape(plotX and bearX ,"Cross down", color=color.red, style=shape.triangledown, location = location.top, size =size.tiny, offset=-1) //plotshape(plotX and bullX ,"Cross up", color=color.green, style=shape.triangleup, location = location.bottom, size =size.tiny, offset=-1) //plotshape(plotRev and bearreverse ,"Bear reversal", color=color.orange, style=shape.triangledown, location = location.top, size =size.tiny, offset=-1) //plotshape(plotRev and bullreverse ,"Bull reversal", color=color.blue, style=shape.triangleup, location = location.bottom, size =size.tiny, offset=-1) //alertcondition(bearX,"Bearish Crossover", "Bearish cross on William %R") //alertcondition(bullX,"Bullish Crossover", "Bullish cross on William %R") //alertcondition(bearreverse,"Bearish Reversal", "Bearish Reversal on William %R") //alertcondition(bullreverse,"Billish Reversal", "Bullish Reversal on William %R") if plotRev and bullreverse strategy.entry("Enter Long", strategy.long) else if plotRev and bearreverse strategy.entry("Enter Short", strategy.short)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6