Skip to main content

Williams %R Strategy

Discover our Williams %R Strategy PineScript template, designed for traders seeking to use Williams %R indicator. Easily backtest on TradingView and live execute this template on AlgoTest.
Adjusting inputs like Williams %R Length, Overbought & Oversold Level, target points, and stop loss points to suit your trading preferences.

info

To learn how to add this pinescript in TradingView, click here.

Williams %R Strategy​

warning

These strategies are for demonstration purposes only and are not intended for actual trading. AlgoTest is not responsible for any profit or loss arising from the use of these sample strategies.

//@version=5
strategy("Williams %R Strategy", overlay=true)

// Input parameters
length = input.int(14, title="Williams %R Length")
overbought_level = input.int(-20, title="Overbought Level")
oversold_level = input.int(-80, title="Oversold Level")
target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")

// Calculate Williams %R
hh = ta.highest(high, length)
ll = ta.lowest(low, length)
williams_r = (hh - close) / (hh - ll) * -100

// Strategy logic
long_condition = williams_r < oversold_level
short_condition = williams_r > overbought_level

// Plot Williams %R
plot(williams_r, color=color.blue, title="Williams %R")

// Strategy entry
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)

// Calculate target and stop loss levels
long_target = strategy.position_avg_price + target_points
long_stop_loss = strategy.position_avg_price - stop_loss_points
short_target = strategy.position_avg_price - target_points
short_stop_loss = strategy.position_avg_price + stop_loss_points

// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)

Understanding the William %R Indicator​

History of the Indicator​

The Williams %R, also known as Williams Percent Range, is a momentum indicator that was developed by Larry Williams in the late 1970s. It is designed to identify overbought and oversold levels in the market, providing insights that are similar to the Stochastic Oscillator but with a unique scaling from 0 to -100.

A Brief About What It Is​

Williams %R is a momentum indicator that measures the level of the close relative to the highest high for the look-back period. It oscillates between 0 and -100, signaling overbought conditions above -20 and oversold conditions below -80. This indicator is particularly useful for pinpointing reversals and confirming trading signals.

How to Use the Indicator for Analysis​

  1. Setting Up: Most commonly, traders set the Williams %R period to 14 days.
  2. Interpreting the Signals: A movement out of the overbought or oversold area is often seen as a signal for potential reversal. For instance, a move above -20 from below suggests a potential decline, and a move up through -80 from below indicates a potential rally.
  3. Combining with Other Indicators: For better accuracy, Williams %R can be combined with other indicators such as the Moving Average Convergence Divergence (MACD) or Relative Strength Index (RSI) to filter out false signals and confirm trends.

Best Use Cases​

  • Stock Trading: Particularly effective in markets with clear trends, as it helps in identifying reversals at an early stage.
  • Forex Trading: Can be used to capture short-term fluctuations in highly liquid forex markets.
  • Commodity Trading: Useful for determining entry and exit points in commodity markets, which are often subject to rapid price changes due to external factors.

FAQ​

Is Williams %R leading or lagging?​

Williams %R is considered a lagging indicator as it uses past price data to generate signals.

What is the difference between RSI and Williams %R?​

Both are momentum indicators, but while RSI scales from 0 to 100, Williams %R scales inversely from 0 to -100. RSI compares upward movements to downward movements, while Williams %R compares the current close to the highest high of the past.

What is the best setting for the Williams %R indicator?​

The typical setting is 14 periods, which can be adjusted based on the trader's analysis timeframe and the asset's volatility.

What is the formula for Williams R?​

The formula for Williams %R is %R=HighestHigh−CloseHighestHigh−LowestLow×−100\%R = \frac{Highest High - Close}{Highest High - Lowest Low} \times -100

For more detailed strategies and settings, visit AlgoTest's Strategy Builder and Signals for practical applications of the Supertrend indicator in real market scenarios.