Strategy object implementing a Bollinger Bands strategy.
This strategy uses only a single indicator, comprised of the TTR function
Parameters for this indicator include number of MA periods, and the size of the bands in standard deviations.
If constructed from scratch, the indicators would consist of:
a moving average parameterized by MA type (simple, exponential, Kalman, etc.) and MA periods to smooth over
the upper band constructed classically by standard deviations from the moving average, or alternately by some other upper band generating function, and parameterized chiefly by the amplitude of the band, typically number of standard deviations from the midpoint or moving average indicator
the lower band traditionally constructed to be symmetrical and opposite the upper band, but potentially constructed via a different function or parameterized differently than the upper band function
The classic Bollinger Bands strategy depends on crossover events (signals) for the upper and lower band and the midpoint.
sigCrossover, if the Close price is greater than the upper band value.
sigCrossover, if the Close price is less than the lower band value.
sigCrossover, if the price at any point crossed the midpoint moving average.
In this strategy, each signal has a corresponding entry or exit rule.
ruleSignal, enter a sell order at market on
ruleSignal, enter a buy order at market on
ruleSignal, enter a market order to close any open position at market on
This strategy may be improved in practice by:
utilizing trailing entry or exit orders
using a different smoothing mechanism other than SMA
the addition of stop-loss rules
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.