Learn R Programming

TTR (version 0.24.4)

WPR: William's %R

Description

William's % R.

Usage

WPR(HLC, n = 14)

Value

A object of the same class as HLC or a vector (if try.xts fails) containing the William's %R values.

Arguments

HLC

Object that is coercible to xts or matrix and contains High-Low-Close prices. If only a univariate series is given, it will be used. See details.

n

Number of periods to use.

Author

Joshua Ulrich

Details

If an High-Low-Close series is provided, the indicator is calculated using the high/low values. If a vector is provided, the calculation only uses that series.

References

The following site(s) were used to code/document this indicator:
https://www.fmlabs.com/reference/WilliamsR.htm
https://www.metastock.com/Customer/Resources/TAAZ/?p=126
https://www.linnsoft.com/techind/williams-r-wpr
https://school.stockcharts.com/doku.php?id=technical_indicators:williams_r

See Also

See stoch.

Examples

Run this code

 data(ttrc)
 stochOsc <- stoch(ttrc[,c("High","Low","Close")])
 stochWPR<- WPR(ttrc[,c("High","Low","Close")])

 plot(tail(stochOsc[,"fastK"], 100), type="l",
     main="Fast %K and Williams %R", ylab="",
     ylim=range(cbind(stochOsc, stochWPR), na.rm=TRUE) )
 lines(tail(stochWPR, 100), col="blue")
 lines(tail(1-stochWPR, 100), col="red", lty="dashed")

Run the code above in your browser using DataLab