BollingerUp
BollingerUp in ProBuilder returns the upper Bollinger Band, a simple moving average plus two standard deviations. Syntax, formula, examples, and gotchas.
Syntax
BollingerUp[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 20 | Lookback period used for both the moving average and the standard deviation. 20 is the setting John Bollinger proposed and remains the most common. |
price | price source | close | The series the band is computed on. Accepts close, open, high, low, typicalprice, or any custom variable. |
Formula
BollingerUp = Average[N](price) + 2 * STD[N](price)The middle band is the N-period simple moving average. The upper band sits two sample standard deviations above it. The multiplier is fixed at 2; a different multiplier requires building the band manually from Average and STD.
How it works
On each bar, ProBuilder computes the simple moving average of the last N values of price, then measures how far those values are dispersed around that average. Two of those standard deviations are added on top of the average to produce the upper band.
Because the standard deviation term reacts to volatility, the band is adaptive. In quiet markets it hugs the moving average; in volatile markets it moves away from it. Under a normal distribution roughly 95 percent of observations fall within two standard deviations, which is why closes beyond the upper band are treated as statistically stretched. Real price data is not normally distributed, so the 95 percent figure is an approximation, not a guarantee.
BollingerUp returns only the upper band. The lower band comes from BollingerDown, the middle band from Average[N](price), and the distance between the bands from BollingerBandWidth.
Examples
Example 1, Detecting a pierce of the upper band (Indicator)
// Flag a bar that opened below the upper band and closed above it
bollU = BollingerUp[20](close)
IF (Open[1] < bollU[1] AND Close[1] > bollU[1]) THEN
VAR = -1
ELSE
VAR = 0
ENDIF
RETURN VAR as "UPPER PIERCING SIGNAL"Checks the previous bar: an open below the band followed by a close above it marks a decisive push through the upper boundary, a pattern some traders read as a breakout attempt.
Example 2, Upper band as a profit target (ProOrder)
// Enter on a cross above the middle band, exit at the upper band
upper = BollingerUp[20](close)
basis = Average[20](close)
IF NOT LongOnMarket AND close CROSSES OVER basis THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF LongOnMarket AND close >= upper THEN
SELL AT MARKET
ENDIFThe middle band acts as the entry trigger and the upper band as a volatility-scaled target. Because the band widens with volatility, the target automatically moves further away in fast markets.
Example 3, Scanning for closes above the upper band (ProScreener)
// List instruments closing above their upper Bollinger Band
upper = BollingerUp[20](close)
stretch = (close - upper) / upper * 100
SCREENER[close > upper](stretch AS "% above band")Returns every instrument in the watchlist whose latest close exceeds the upper band, sorted by how far above it the close sits.
Interpretation
| Situation | Common reading |
|---|---|
| Close touches or exceeds the band | Price is statistically stretched to the upside. In ranges this often precedes a pullback toward the middle band. |
| Price rides along the band for many bars | A strong uptrend, sometimes called walking the band. Fading it is unreliable. |
| Band turns sharply away from price | Volatility contraction; often follows a climax move. |
A close above the upper band is not by itself a sell signal. Bollinger described band touches as tags, information about where price sits relative to recent volatility, to be combined with other evidence.
Common errors and gotchas
- Wrong bracket type.
BollingerUp(20, close)raises a syntax error. The period uses square brackets, the price source uses parentheses:BollingerUp[20](close). - Fading every band touch. In strong trends price can close above the upper band for many consecutive bars. Counter-trend logic keyed only to the band is a common backtest trap.
- Fixed multiplier. The deviation multiplier cannot be changed through the function. For 1.5 or 2.5 deviations, compute
Average[N](price) + m * STD[N](price)directly. - Insufficient history. The value is unreliable until at least
Nbars are available. In ProOrder, raisePRELOADBARSif signals near the start of the run look wrong.
Related instructions
BollingerDown, the matching lower band.BollingerBandWidth, distance between the two bands, a volatility gauge.STD, standard deviation, the building block for custom multipliers.Average, the middle band and general-purpose moving average.KeltnerBandUp, ATR-based alternative upper envelope.KeltnerBandDown, ATR-based lower envelope.DonchianChannelUp, highest-high channel, a non-statistical envelope.RSI, bounded oscillator often paired with band touches for confirmation.
