About
This plugin exists to be read. It shows the whole shape of an indicator plugin in one file: a class that takes one bar per update, keeps only the window it needs, returns None while it warms up, and exposes extra lines as properties beside value.
The engine already has Bollinger Bands built in (ctx.ind("bb")), drawn on the chart and available in every language. Use that one in a strategy; use this one as the starting point for an indicator of your own.
Parameters
| Name | Type | Default | Range or options | Description |
|---|---|---|---|---|
period | int | 20 | min 2, max 200 | Bars in the window the average and the standard deviation are taken over. |
mult | float | 2 | min 0.5, max 5 | How many standard deviations the upper and lower band sit from the middle. |
Use it in a strategy
pythonbands = ctx.plugin_indicator("bollinger_bands", "bollinger", {"period": 20, "mult": 2.0})
if bands is not None and bands.value is not None:
close = ctx.bars(1)[-1].close
if close < bands.lower:
ctx.signal("LONG")What it provides
valueValue | The middle band, the simple moving average of the close. None during warm up. |
upperValue | The middle band plus mult population standard deviations. |
lowerValue | The middle band minus mult population standard deviations. |
Limits
- A plugin indicator is not drawn on the chart and is not available in Blocks, Pine, Rust or C#; it runs on the run's own instrument only.