Analytics > Indicators > Williams %R |
Williams %R indicator for the FinancialChart is a momentum indicator, which compares the current asset price to the highest price over the look back period. Its look-back is typically 14 periods. The indicator fluctuates between 0 and -100. It is the inverse of a fast Stochastic Oscillator. While the Williams %R displays the level of a stock's close relative to the highest high for the look-back period, the Stochastic Oscillator shows the level of a stock's close relative to the lowest low. Both the indicators show same lines, however scaling is different. It finds application in determining Overbought/Oversold levels, providing buy and sell signals, and momentum confirmations.
The following code snippet creates an instance of the WilliamsR class to use the indicator.
Partial Public Class Indicators Inherits UserControl Private dataService As DataService = dataService.GetService() Private wr As New WilliamsR() With { Key.SeriesName = "WilliamsR" } Public Sub New() InitializeComponent() End Sub Public ReadOnly Property Data() As List(Of Quote) Get Return dataService.GetSymbolData("box") End Get End Property Public ReadOnly Property IndicatorType() As List(Of String) Get Return New List(Of String)() From { "Williams %R" } End Get End Property Private Sub OnIndicatorTypeSelectionChanged(sender As Object, e As SelectionChangedEventArgs) Dim ser As FinancialSeries = Nothing If cbIndicatorType.SelectedIndex = 0 Then ser = wr End If If ser IsNot Nothing AndAlso Not indicatorChart.Series.Contains(ser) Then indicatorChart.BeginUpdate() indicatorChart.Series.Clear() indicatorChart.Series.Add(ser) indicatorChart.EndUpdate() End If End Sub Private Sub OnFinancialChartRendered(sender As Object, e As C1.WPF.Chart.RenderEventArgs) If indicatorChart IsNot Nothing Then indicatorChart.AxisX.Min = DirectCast(financialChart.AxisX, IAxis).GetMin() indicatorChart.AxisX.Max = DirectCast(financialChart.AxisX, IAxis).GetMax() End If End Sub End Class
public partial class Indicators : UserControl { DataService dataService = DataService.GetService(); WilliamsR wr = new WilliamsR() { SeriesName = "WilliamsR" }; public Indicators() { InitializeComponent(); } public List<Quote> Data { get { return dataService.GetSymbolData("box"); } } public List<string> IndicatorType { get { return new List<string>() { "Williams %R" }; } } void OnIndicatorTypeSelectionChanged(object sender, SelectionChangedEventArgs e) { FinancialSeries ser = null; if (cbIndicatorType.SelectedIndex == 0) ser = wr; if (ser != null && !indicatorChart.Series.Contains(ser)) { indicatorChart.BeginUpdate(); indicatorChart.Series.Clear(); indicatorChart.Series.Add(ser); indicatorChart.EndUpdate(); } } void OnFinancialChartRendered(object sender, C1.WPF.Chart.RenderEventArgs e) { if (indicatorChart != null) { indicatorChart.AxisX.Min = ((IAxis)financialChart.AxisX).GetMin(); indicatorChart.AxisX.Max = ((IAxis)financialChart.AxisX).GetMax(); } } }