Williams %R

Overview

Williams %R, or just %R, is a momentum indicator showing the current closing price in relation to the high and low of the past N days (for a given N). It was developed by trader and author Larry Williams and is used in the stock and commodities markets.

AnyChart Stock allows you to add Williams %R with desired period to any of your charts.

Mathematical description of the indicator please see at: Mathematical Description of Technical Indicators

to top

Adding indicator

To add any indicator to the chart, you need to use Data Provider with the fields required by the indicator. When such Data Provider is ready - you can add indicator to the chart.

Preparing Data Provider

Williams %R indicator needs Data Provider with High, Low and Close fields.

Sample XML of Data Provider, which can be used to create %R indicator:

XML/JSON Syntax
Plain code
03     <data_provider data_set="dataSet1" id="dp1">
04       <fields>
05         <field type="High" column="2" approximation_type="High" />
06         <field type="Low" column="3" approximation_type="Low" />
07         <field type="Close" column="4" approximation_type="Close" />
08       </fields>
09     </data_provider>
01{
03    {
04      dataSet: "dataSet1",
05      id: "dp1",
06      fields: [
07        {
08          type: "High",
09          column: 2,
10          approximationType: "High"
11        },
12        {
13          type: "Low",
14          column: 3,
15          approximationType: "Low"
16        },
17        {
18          type: "Close",
19          column: 4,
20          approximationType: "Close"
21        }
22      ]
23    }
24  ]
25}

to top

Indicator Declaration

As soon as Data Provider is ready you can add an indicator to a chart.

Williams %R indicator is usually shown on the chart below the chart with data (stock data). So we should declare it in another chart. Learn more about charts and layout in Chart Layout article.

XML for %R declaration:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="WilliamsR" data_provider="dpMsft" />
05 </chart>
01{
03    {
04      type: "WilliamsR",
05      dataProvider: "dpMsft"
06    }
07  ]
08}

Another important thing is the fact that Williams %R is measured on a -100 — 0 scale, so to show it properly we need to configure value axis scale in the chart with indicator, like that, for example:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="WilliamsR" data_provider="dpMsft" />
05   <value_axes>
06     <primary>
07       <scale minimum_mode="CustomValue" minimum="-100" maximum_mode="CustomValue" maximum="0" interval_mode="CustomValue" interval="20" />
08     </primary>
09   </value_axes>
10 </chart>
01{
03    {
04      type: "WilliamsR",
05      dataProvider: "dpMsft"
06    }
07  ],
08  valueAxes: {
09    primary: {
10      scale: {
11        minimumMode: "CustomValue",
12        minimum: -100,
13        maximumMode: "CustomValue",
14        maximum: 0,
15        intervalMode: "CustomValue",
16        interval: 20
17      }
18    }
19  }
20}

Of course you can use other steps or margins, if you'd like to, as described in Y-Axes Settings article.

After all things mentioned above are done, you can create a chart with Williams %R indicator, see basic Live Sample with it below:

Live Sample:  Technical Indicators - Adding WilliamsR Indicator

to top

Indicator parameters

Williams %R has only one type specific parameter - period. Period is set in <williams_r_indicator> node, where all settings for %R indicator are set.

XML for setting %R period:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="WilliamsR" data_provider="dpMsft">
04       <williams_r_indicator period="20" />
05     </technical_indicator>
07 </chart>
01{
03    {
04      type: "WilliamsR",
05      dataProvider: "dpMsft",
06      williamsRIndicator: {
07        period: 20
08      }
09    }
10  ]
11}

As you can see you just need to set period attribute in <williams_r_indicator> node, this attribute accepts any integer greater than 1.

Live sample:

Live Sample:  Technical Indicators - WilliamsR Parameters

to top

Visualization

To visualize and tune visualization of technical indicators AnyChart Stock Component uses the same methods as for the data series.

By default Williams %R is shown as series of Line type, but you can use almost any of available series types to show it on the chart - Spline, Area or Stick, for example.

Williams %R indicator settings are contained in <williams_r_indicator> node, also in this node you can put <series> subnode - this node defines how exactly indicator is displayed on the chart. This node is identical to <series> node used to describe data series, so you can do with indicator anything you can do with series.

Sample XML for changing indicator visualization:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="WilliamsR" data_provider="dpMsft">
04       <williams_r_indicator period="14">
05         <series type="Area" color="#1EA64E">
06           <name><![CDATA[Williams %R(14):]]></name>
07           <area_series>
08             <fill color="%Color" opacity="0.6" />
09             <line thickness="1" color="DarkColor(%Color)" opacity="1" />
10           </area_series>
11         </series>
12       </williams_r_indicator>
13     </technical_indicator>
15 </chart>
01{
03    {
04      type: "WilliamsR",
05      dataProvider: "dpMsft",
06      williamsRIndicator: {
07        period: 14,
08        series: {
09          type: "Area",
10          color: "#1EA64E",
11          name: "Williams %R(14):",
12          areaSeries: {
13            fill: {
14              color: "%Color",
15              opacity: 0.6
16            },
17            line: {
18              thickness: 1,
19              color: "DarkColor(%Color)",
20              opacity: 1
21            }
22          }
23        }
24      }
25    }
26  ]
27}

Also, in some cases you may want to omit minus sign in indicator legend, to do that you should modify legend item format according to rules described in Number formatting article.

Formatting for legend in mouse over state looks like shown below, where negativeSignStyle:None makes negative values appear without minus sign:

XML/JSON Syntax
Plain code
01 <format><![CDATA[{%SeriesIcon} <b><font color="%Color">{%SeriesName} {%Value.Current}{numDecimals:2,negativeSignStyle:None}</font></b> ]]></format>
01{
02  value: "{%SeriesIcon} <b><font color=\"%Color\">{%SeriesName} {%Value.Current}{numDecimals:2,negativeSignStyle:None}</font></b> "
03}

Live sample below shows all settings mentioned above:

Live Sample:  Technical Indicators - WilliamsR Visualization Settings

to top

Overbought/Oversold Visualization

Williams %R is a momentum indicator that works much like the Stochastic Oscillator. It is especially popular for measuring overbought and oversold levels. The scale ranges from 0 to -100 with readings from 0 to -20 considered overbought, and readings from -80 to -100 considered oversold.

To chart Overbought and Oversold signals in AnyChart Stock you can use Line or Range axis markers with labels, which are described in

Live sample below shows Williams %R with labeled line axis markers used to highlight Overbought and Oversold signals:

Live Sample:  Technical Indicators - WilliamsR with Overbought and Oversold signals

to top