A Guide to Williams Percent Range (Williams %R) Indicator

Article

Assisted by AI

Discover how to effectively integrate the Williams Percent Range (Williams %R) indicator into your software applications.
Soroush Sohrabian

Ahmad Omid

Data Science Developer

LinkedIn icon
Williams-Percent-range-Cover

What is the Williams %R Indicator?

The Williams Percent Range (Williams %R) is a momentum-based technical indicator used to identify overbought and oversold market conditions. Developed by Larry Williams, it measures the current closing price relative to the highest and lowest prices over a specific period, typically 14 days.

The indicator oscillates between 0 and -100, where values above -20 indicate overbought conditions and values below -80 suggest oversold conditions. Traders use the Williams %R indicator to anticipate potential reversals in price movements.

How to Use the Williams %R Indicator in Forex?

Forex traders utilize the Williams Percent Range to assess the momentum of currency pairs and identify potential trading opportunities. When the indicator enters the overbought zone (above -20), it signals that the currency pair may be overvalued and due for a downward correction.

Conversely, when it moves into the oversold zone (below -80), it suggests that the asset is undervalued and may soon rise. However, traders should confirm these signals with additional technical analysis tools such as trend lines or moving averages before executing trades.

Examples of Williams %R Trading Strategies

  1. Overbought and Oversold Strategy: Traders enter sell positions when Williams %R moves from overbought (-20) to a lower level and enter buy positions when it moves from oversold (-80) to a higher level.
  1. Divergence Strategy: A bearish divergence occurs when price reaches a new high, but the Williams %R fails to do the same, indicating potential weakness. A bullish divergence happens when price forms a new low, but the indicator does not, signaling a possible upward reversal.
  1. Trend Confirmation: In trending markets, traders use Williams %R to confirm entries. In an uptrend, they look for pullbacks where the indicator exits oversold territory. In a downtrend, they wait for the indicator to leave the overbought zone before entering short positions.

Formula

The Williams %R is calculated using the following formula:

Williams-Percent-range-Formula

Where:

  • HighestHigh = The highest price over the lookback period (e.g., 14 days)
  • LowestLow = The lowest price over the same period
  • ClosePrice = The most recent closing price

Interpretation

    • If Williams %R is above -20, it signals an overbought condition and a possible price decline.
    • If Williams %R is below -80, it suggests an oversold condition and a potential price increase.
    • The indicator moves between 0 and -100, helping traders analyze momentum shifts and possible trend reversals.

    Calculation Example

    Assume the following price data over a 14-day period:

    • Highest High: 1.2200
    • Lowest Low: 1.1900
    • Close Price: 1.2000

    Applying the Williams %R formula:

    Williams-Percent-range-Formula-Example

    Since the value is between -20 and -80, the market is considered neutral, meaning there is no strong buy or sell signal.

    How to Create the Technical Indicator Using LC JS Trader

    Step 1: Get LightningChart JS Trader

    To begin, you’ll need access to LightningChart JS Trader. This library provides the tools necessary to create advanced technical indicators, including the Williams Percent Range Indicator. Visit the LightningChart JS Trader page to download the required components and review the documentation.

    Step 2: Review the Interactive Example

    LightningChart JS Trader includes interactive examples that demonstrate how to create custom technical indicators. Start by reviewing the documentation, focusing on how to integrate the Williams Percent Range Indicator into your chart setup. The interactive examples will guide you through the process of setting up the Williams Percent Range Indicator, from importing the necessary modules to modify the chart settings.

    Step 3: Code Explanation

    In this step, we will break down the code that creates the chart with the Williams Percent Range Indicator, as shown in the image, using LightningChart JS Trader. The code demonstrates how to initialize a trading chart, apply the Williams Percent Range Indicator, and customize its appearance.

    Williams-Percent-range-Chart

    Here’s a detailed breakdown of each section:

    A. Importing the Required Libraries:

       const lcjsTrader = require('@arction/lcjs-trader')
       const lcjs = require('@arction/lcjs')
       const { Themes } = lcjs
    • lcjsTrader: This library provides access to the LightningChart JS Trader functionalities, allowing you to create advanced financial charts.
    • lcjs: The main LightningChart JS library, used for general charting functionality.
    • Themes: A property within lcjs that provides access to pre-built themes. In this case, we are using the darkGold theme to style the chart.

    B. Initializing the Trading Chart:

       lcjsTrader.trader(TRADER_LICENSE).then(async (trader) => {
        // Create a trading chart.
        const tradingChart = trader.tradingChart({ loadFromStorage: false, colorTheme: Themes.darkGold })
    • trader(TRADER_LICENSE): Initializes the LightningChart JS Trader with the provided license key (TRADER_LICENSE). This is required to access the charting functionalities for financial data.

    Note you can request a LightningChart JS Trader trial license, which is free.

    • tradingChart(): This function creates a trading chart with certain options.
    • loadFromStorage: false: This disables the loading of previously stored chart data from local storage, ensuring a fresh chart setup.
    • colorTheme: Themes.darkGold: This applies the darkGold theme to the chart, which influences the background color, gridlines, and other visual elements.

    C. Adding and Customizing the Indicator

        // Add a Williams Percent Range indicator
        const wpr = tradingChart.indicators().addWilliamsPercentRange()
        wpr.setPeriodCount(14)
        wpr.setSource(3)
        wpr.setOversoldAndOverboughtRanges(-80, -20)
        wpr.setLineColor('#FFDD33')
        wpr.setLineWidth(3)
    • addWilliamsPercentRange(): Williams %R measures overbought and oversold levels by comparing the current closing price to the high-low range over a specific time period.
    • wpr.setPeriodCount(14): Sets the number of time periods (n) used to calculate the indicator.
    • **wpr.setSource(3): Sets which values the indicator calculations are based on. In this case, 3 represents the Close value.
    • wpr.setOversoldAndOverboughtRanges(-80, -20): Sets the values for oversold and overbought ranges (oversoldRange, overboughtRange).
    • wpr.setLineColor('#FFDD33’): Sets the color of the oscillator line to a shade of yellow.
    • wpr.setLineWidth(3): Sets the width of the oscillator line to 3 pixels.

    D. Loading Data from a CSV File

        // Reading data from a file.
        await fetch(`${document.head.baseURI}examples/assets/0000/Alphabet Inc (GOOGL).csv`).then((res) => res.text()).then((text) => {
            tradingChart.readCsvString(text, 'Alphabet Inc (GOOGL)')
        })
    • fetch(): This function retrieves a CSV file containing historical data for Alphabet Inc. (GOOGL). The CSV file includes pricing information for the company’s stock, which is plotted on the chart.
    • readCsvString(): This function reads the CSV data and interprets it as pricing data for Alphabet Inc. The second argument (‘Alphabet Inc (GOOGL)’) sets the label for the chart, as seen at the top of the chart image.

    E. Setting the Currency for the Chart

        tradingChart.setCurrency('USD')
       })
    • setCurrency('USD'): This sets the currency of the chart to USD, ensuring that the pricing data is interpreted and displayed in US dollars.

    ** Enumeration Source in LC JS Trader: To select which values the indicator calculations are based on.

    Rainbow-oscillator-Table

    Advantages and Limitations of the Indicator

    The Williams Percent Range indicator offers several advantages that make it a popular choice among traders. One of its key benefits is its simplicity and ease of interpretation. Even beginner traders can use it to identify overbought and oversold market conditions.

    Additionally, it is highly effective in range-bound markets, where prices fluctuate within a specific range, helping traders spot potential reversal points. Another advantage is its ability to identify divergence, which can signal trend reversals before they occur.

    This makes it useful for traders looking to enter or exit positions at optimal times. Furthermore, the Williams %R is a fast-reacting indicator, meaning it responds quickly to price movements, allowing traders to make timely decisions.

    Despite its strengths, the Williams Percent Range indicator has certain limitations. One major drawback is that it can produce false signals in trending markets, leading traders to enter premature or incorrect trades. Since strong trends can keep the indicator in overbought or oversold territory for extended periods, relying solely on Williams %R may result in missed opportunities or losses.

    Another limitation is its lagging nature, as it is derived from past price movements and does not predict future price action. Because of this, traders must be cautious when using it as a standalone tool.

    Additionally, the indicator requires confirmation from other technical analysis tools, such as the Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD), or moving averages. Combining Williams %R with other indicators helps filter out false signals and improves the accuracy of trade decisions.

    Conclusion

    The Williams Percent Range (Williams %R) indicator is a valuable tool for traders who want to identify overbought and oversold market conditions.

    By understanding its calculation, interpretation, and various trading strategies, traders can effectively use it to improve their market timing and enhance their trading decisions.

    However, like any technical indicator, Williams %R should not be used in isolation. Combining it with other technical analysis tools such as moving averages, RSI, and MACD can significantly improve its reliability and effectiveness.

    To fully leverage the power of the Williams Percent Range indicator, it is crucial to use a robust and interactive charting environment.

    This is where LightningChart JS Trader comes into play. LightningChart JS Trader provides high-performance, real-time visualization capabilities, making it an ideal platform for traders looking to analyze technical indicators, including the Williams %R, with precision and clarity.

    Moreover, LightningChart JS Trader offers superior charting performance, ensuring fast and responsive data rendering for traders dealing with large datasets. This is particularly important in forex and stock trading, where real-time data is essential for making timely trading decisions.

    Continue learning with LightningChart

    Using Scale Breaks in Data Visualization

    Using Scale Breaks in Data Visualization Starting from LightningChart® .NET version 8, X axes has supported Scale breaks. Scale breaks allow excluding specific X ranges, e.g. inactive trading hours/dates or machinery off-production hours. In effect, scale breaks allow...

    Lighting

    This article covers basics of Lighting in Data Visualization.