TradingView indicator guide

Bull Bear Index indicator: the four-SMA BBI on TradingView

The Bull Bear Index indicator covered here is BBI = (SMA(close, 3) + SMA(close, 6) + SMA(close, 12) + SMA(close, 24)) / 4. It combines four price averages into one line on the chart. A close above BBI is above this blended average; it does not establish a profitable buy signal. The name also appears on sentiment measures and unrelated scripts, so identify the formula before comparing readings.

See the decision guide

Identify which Bull Bear Index you mean

Public BBI descriptions by TradingView authors AgentC and xbj use the four lengths 3, 6, 12 and 24. Those published formulas establish the convention used here; this page independently implements the arithmetic. It does not reproduce a protected script, its hidden filters, or any proprietary bank model.

  • A published three-average BBI variant uses 6, 12 and 24. Removing the three-bar component changes the result; it is not the four-average calculation below.
  • Use standard candles when you want actual bar closes. Heikin Ashi and other synthetic chart prices change the input.
Name or variantInputs and calculationMeaning of the output
Four-SMA BBI on this pageFour closing-price SMAs, averaged equallyA line in the same units as price
Elder Ray Bull Bear PowerHigh minus an EMA of close; low minus that EMADistances above and below an EMA
Bank or survey bull/bear sentiment measureProvider-specific sentiment, positioning or survey inputsA separate methodology; four chart averages cannot reproduce it
Other scripts named BBICheck the author, source, lengths and smoothingThe title alone does not identify the formula

Equal average weights are unequal price weights

For a length N, SMA(close, N) sums the current close and the previous N minus one closes, then divides by N. Average the four SMA values with divisor 4. With the default lengths, recent closes appear in more of those windows and therefore carry more weight. The table gives the exact coefficient of each individual close.

  • The coefficients sum to 1. A 24-bar SMA instead assigns every close 1/24, so it is a different filter even though both require 24 bars of history.
  • On a five-minute chart, 24 means 24 five-minute bars. It means 24 daily observations only on a daily chart. Market closures do not add empty observations.
  • Lengths need not be ordered: the longest controls warmup. Repeated lengths are allowed but repeat that component weight. Four identical lengths reduce exactly to one SMA.
Age of close, current = 0Coefficient in BBITotal weight of this group
0 to 2 bars ago(1/3 + 1/6 + 1/12 + 1/24) / 4 = 15/963 × 15/96 = 46.875%
3 to 5 bars ago(1/6 + 1/12 + 1/24) / 4 = 7/963 × 7/96 = 21.875%
6 to 11 bars ago(1/12 + 1/24) / 4 = 3/966 × 3/96 = 18.75%
12 to 23 bars ago(1/24) / 4 = 1/9612 × 1/96 = 12.5%

Recalculate all four components and a price crossing

Use a hypothetical series whose first 24 closes are 1, 2, 3, through 24 in arbitrary price units. On bar 24, the latest three closes total 69; the latest six total 129; the latest twelve total 222; all 24 total 300. Then append closes of 10 and 25. These inputs are arithmetic fixtures, not market observations.

  • On bar 24, BBI = (23 + 21.5 + 18.5 + 12.5) / 4 = 18.875. A 12-bar SMA is 18.5 and a 24-bar SMA is 12.5. Neither is interchangeable with BBI.
  • A cross above requires current close > current BBI and previous close <= previous BBI. A cross below requires current close < current BBI and previous close >= previous BBI. Equality on the current bar is not a cross.
  • Bar 24 has a valid BBI but no valid BBI on bar 23, so it cannot establish a crossing. Bar 25 goes from 24 > 18.875 to 10 < 17.53125. Bar 26 reverses that relation.
  • Round only for display. Evaluate crossings with the unrounded values and the same symbol, feed, session and adjustment settings.
Bar / closeSMA 3SMA 6SMA 12SMA 24BBI / crossing
24 / 2469/3 = 23129/6 = 21.5222/12 = 18.5300/24 = 12.518.875; no previous BBI
25 / 1057/3 = 19120/6 = 20219/12 = 18.25309/24 = 12.87517.53125; cross below
26 / 2559/3 = 19.666667125/6 = 20.833333230/12 = 19.166667332/24 = 13.83333318.375; cross above

Four averages still whipsaw in a range

For a separate hypothetical path, start with 24 closes of 100, then append 104, 96, 104 and 96. A valid prior BBI exists before the first jump. Both BBI and a single 24-bar SMA generate alternating crossings on all four new bars. Combining averages does not remove this failure mode.

  • For the first jump, BBI moves by 4 × 15/96 = 0.625 while SMA 24 moves by 4/24 = 0.166667. That stronger immediate response is a consequence of the weights, not evidence of better trades.
  • On a steady rise of one unit per bar after warmup, BBI is 5.125 units behind the latest close; SMA 24 is 11.5 units behind. This is their weighted mean bar age for that constructed path, not a universal turning-point delay.
  • A close-above-BBI state can persist for many bars without another crossing. Conversely, treating every crossing as a new trend produces repeated reversals in this range example.
  • A slope requirement, distance buffer or persistence rule changes the signals and delays some entries. Test such rules separately with defined exits, fees and slippage; this example does not select a profitable filter.
Bar / closeBBISMA 24Confirmed close crossing
24 / 100100100No crossing; equality
25 / 104100.625100.166667Above both lines
26 / 96100100Below both lines
27 / 104100.625100.166667Above both lines
28 / 9699.666667100Below both lines

Pine Script v6 with explicit warmup and confirmed crossings

Paste this complete indicator into the TradingView Pine Editor and add it to a standard chart. The four lengths are editable, the source is close, and all calculations use the chart timeframe. The Data Window exposes the four components after warmup. The current open bar has no plotted BBI until it closes.

  • The longest length sets the required consecutive history. A missing close anywhere in that window makes BBI unavailable; the code does not fill missing prices with zero or shorten the window.
  • Crossings need two adjacent valid BBI values. After a missing-data gap, the first valid value restores the line but cannot itself trigger a crossing.
  • The confirmation gate prevents a temporary intrabar crossing from producing a marker or alert condition. It does not protect against later data-feed revisions, and it is not a higher-timeframe confirmation method.
  • Create an alert from the named condition in TradingView and select Once Per Bar Close. The script alone does not create a running alert. Recreate alerts after changing inputs or source code because existing alerts use a saved snapshot.
Independent implementation of the disclosed four-SMA formula. Pineify syntax checking returned no errors on 2026-10-18. This is an indicator with alert conditions, not an order-executing strategy.pine
//@version=6
indicator("Four-SMA BBI audit", overlay = true, precision = 6)
n1 = input.int(3, "SMA 1 bars", minval = 1, maxval = 1000)
n2 = input.int(6, "SMA 2 bars", minval = 1, maxval = 1000)
n3 = input.int(12, "SMA 3 bars", minval = 1, maxval = 1000)
n4 = input.int(24, "SMA 4 bars", minval = 1, maxval = 1000)
longest = math.max(n1, n2, n3, n4)
ma1 = ta.sma(close, n1)
ma2 = ta.sma(close, n2)
ma3 = ta.sma(close, n3)
ma4 = ta.sma(close, n4)
missingCount = math.sum(na(close) ? 1.0 : 0.0, longest)
ready = bar_index >= longest - 1 and missingCount == 0
bbi = ready ? (ma1 + ma2 + ma3 + ma4) / 4.0 : na
crossUp = ta.crossover(close, bbi)
crossDown = ta.crossunder(close, bbi)
validPair = not na(bbi) and not na(bbi[1]) and not na(close[1])
confirmed = barstate.isconfirmed
up = confirmed and validPair and crossUp
down = confirmed and validPair and crossDown
plot(confirmed ? bbi : na, "BBI", color = color.blue, linewidth = 2, style = plot.style_linebr)
plot(confirmed and ready ? ma1 : na, "SMA 1", display = display.data_window)
plot(confirmed and ready ? ma2 : na, "SMA 2", display = display.data_window)
plot(confirmed and ready ? ma3 : na, "SMA 3", display = display.data_window)
plot(confirmed and ready ? ma4 : na, "SMA 4", display = display.data_window)
plotshape(up, "Close crossed above BBI", shape.triangleup, location.belowbar, color.blue, text = "UP", size = size.tiny)
plotshape(down, "Close crossed below BBI", shape.triangledown, location.abovebar, color.orange, text = "DOWN", size = size.tiny)
alertcondition(up, "Close above BBI", "Confirmed close crossed above the four-SMA BBI.")
alertcondition(down, "Close below BBI", "Confirmed close crossed below the four-SMA BBI.")

Use the formula as the acceptance test for an AI draft

The Pine Script AI Coding Agent can draft or revise an indicator from your written rules and request syntax diagnostics. Provide the four SMA lengths, close source, equal component weights, consecutive-history requirement and confirmed price-crossing rule. Compare the generated components with the fixtures above before adapting the script.

  • Keep all four SMA values visible while checking the output. A script that silently substitutes EMAs, omits a component or compares close with the previous BBI implements a different rule.
  • If you want a strategy, specify order timing, exits, sizing and costs separately. Compiling the indicator proves neither its numerical equivalence to an unknown script nor its profitability.
Where Pineify fits

Pine Script AI Coding Agent

Draft or revise the disclosed BBI calculation, request syntax checking, then compare the four component averages and crossing timestamps in TradingView.

Draft a BBI indicator

Frequently asked questions

Educational information, not investment advice. Price sequences are hypothetical calculations, not backtest results. Moving-average crossings and successful syntax validation do not establish profitability.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.