PBands | R Documentation |
John Bollinger's famous adaptive volatility bands most often use the typical
price of an HLC series, or may be calculated on a univariate price series
(see BBands
).
PBands(
prices,
n = 20,
maType = "SMA",
sd = 2,
...,
fastn = 2,
centered = FALSE,
lavg = FALSE
)
prices |
A univariate series of prices. |
n |
Number of periods to average over. |
maType |
A function or a string naming the function to be called. |
sd |
The number of standard deviations to use. |
... |
any other pass-thru parameters, usually for function named by
|
fastn |
Number of periods to use for smoothing higher-frequency 'noise'. |
centered |
Whether to center the bands around a series adjusted for high
frequency noise, default |
lavg |
Whether to use a longer |
This function applies a second moving average denoted by fastn
to
filter out higher-frequency noise, making the bands somewhat more stable to
temporary fluctuations and spikes.
If centered
is TRUE
, the function also further smoothes and
centers the bands around a centerline adjusted to remove this higher
frequency noise. If lavg
is also TRUE
, the smoothing applied
for the middle band (but not the volatility bands) is doubled to further
smooth the price-response function.
If you have multiple different price series in prices
, and want to use
this function, call this functions using lapply(prices,PBands,...)
.
A object of the same class as prices
or a matrix (if
try.xts
fails) containing the columns:
The lower price volatility Band.
The smoothed centerline (see details).
The upper price volatility Band.
Brian G. Peterson
BBands
data(ttrc)
pbands.close <- PBands( ttrc[,"Close"] )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.