WilliamsR

Modified on 2017/08/22 13:26 by Eugene — Categorized as: Standard Indicators

Syntax

public static WilliamsR Series(Bars bars, int period)
public WilliamsR(Bars bars, int period, string description)

Parameter Description

bars The Bars object
period Indicator calculation period

Description

Williams %R is a momentum indicator developed by Larry Williams. Like Stochastic Oscillators (StochK, StochD), WilliamsR is used to gauge overbought and oversold levels, and ranges between 0 and 100. However, unlike most other momentum oscillators, the low end of the scale represents an overbought area, and the high end an oversold condition. For this reason Williams %R is often multiplied by -1 and plotted on a negative scale.

Williams %R measures the latest closing price relative to high low range within the past data, thus it reflects buyers and sellers commitment to close the price within that range. At the peak of the buyer's power the oscillator reaches zero, and at the peak of the seller's power, it reaches 100. The overbought region is below 10 percent and the oversold region is over 90 percent.

Interpretation

A reading of above 80 or 90 indicates oversold levels, and below 20 or 10 indicates overbought. Williams %R has a tendency to peak ahead of price, so it can be a good tool in identifying trend reversals. During strong trends, the Williams %R can remain in the oversold or overbought regions for extended periods of time.


Calculation

Wm%R = 100 * ( Hn - C ) / ( Hn - Ln )

where,

n = period, such as 7 days
Hn = Highest high in last n periods
Ln = Lowest low in last n period
C = closing price of latest bar


Note that Williams %R readings may contradict standards - the common wisdom is to use an inversed scale from 0 to -100. As a workaround, multiply the final result by -1:
DataSeries PctR = WilliamsR.Series( Bars, 14 );
PctR *= -1;



Example

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // Color the chart background for smoothed Williams %R oversold and overbought levels

DataSeries PctR = WilliamsR.Series( Bars, 14 ); DataSeries SmoothR = WilderMA.Series( PctR, 4 ); ChartPane PctRPane = CreatePane( 35, true, true ); PlotSeries( PctRPane, PctR, Color.SaddleBrown, WealthLab.LineStyle.Solid, 1 ); PlotSeries( PctRPane, SmoothR, Color.Black, WealthLab.LineStyle.Solid, 1 ); Color RedBkg = Color.FromArgb(255, 227, 231); Color BlueBkg = Color.FromArgb(50,0,100,255);

for(int bar = 20; bar < Bars.Count; bar++) { if( SmoothR[bar] < 20 ) SetBackgroundColor( bar, RedBkg ); else if( SmoothR[bar] > 80 ) SetBackgroundColor( bar, BlueBkg ); } } } }