Indicator · Pine Script v5 · On the chart

Body Mass Indicator

by harryguiacorn· code credited to FxCloudTrader

The Body Mass Indicator highlights candles with exceptionally large body ranges relative to recent price movement.

View on GitHub

GitHub stars219on the repository
Pine versionv5runs as is
Lines of code32
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago8 May 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

32 lines of Pine Script v5 from BodyMassIndicator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

BodyMassIndicator.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FxCloudTrader

//@version=5
indicator("Body Mass Indicator", "BMI", overlay = true)
enableBodyMass      = input.bool(true, "5.1 Enable Body Mass Indicator")
enableBodyATRMass   = input.bool(false, "5.2 Enable Body Mass ATR Indicator")
lookbackperiod = input.int(26, "Look back periods")
noOfAtr = input.int(1, "Number of ATRs vs body mass")

BodyRange() =>
    math.abs(close - open) 

// Get the highest body range of the past number of bars
highestBodyRange = ta.highest(BodyRange(), lookbackperiod)

if highestBodyRange==BodyRange() and enableBodyMass
    if close > open
        label.new(bar_index, na, "▲\n" + str.tostring(highestBodyRange, format.mintick), yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)
    else if close < open
        label.new(bar_index, na, str.tostring(highestBodyRange, format.mintick) + "\n▼", yloc = yloc.abovebar, style = label.style_none, textcolor = color.black, size = size.normal)

if BodyRange()> ta.atr(lookbackperiod) * noOfAtr and enableBodyATRMass
    if close > open
        label.new(bar_index, na, "▲\n" + str.tostring(BodyRange(), format.mintick), yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)
    else if close < open
        label.new(bar_index, na, str.tostring(BodyRange(), format.mintick) + "\n▼", yloc = yloc.abovebar, style = label.style_none, textcolor = color.black, size = size.normal)

//Display every candlestick range for testing environment
// label.new(bar_index[0], na, str.tostring(BodyRange(), format.mintick) + "", yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)

// plotshape(highestBodyRange==BodyRange()?highestBodyRange:na,   title = 'Body Mass',  style=shape.flag, location=location.bottom, offset=0, color=color.new(color.yellow, 50), size=size.small, display = enableBodyMass?display.all:display.data_window)

Overview

Body Mass Indicator calculates the absolute distance between open and close prices. When enabled, it identifies bars where the body range achieves a new high over a specified lookback period or exceeds a defined multiple of the Average True Range (ATR). The script overlays directional labels and exact point values directly above or below candles on the main price chart. Settings allow traders to adjust the lookback period, toggle ATR threshold comparisons, and scale the ATR multiplier.

Details

Published by

harryguiacorn on GitHub

Code credit

FxCloudTrader, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Volatility & bands, Candlestick patterns

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

bollingerbollinger-bandbollinger-bandsichimokuichimoku-cloudichimoku-indicatorpinepinescriptpinescript-guidespinescript-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
5.1 Enable Body Mass IndicatorbooltrueenableBodyMass
5.2 Enable Body Mass ATR IndicatorboolfalseenableBodyATRMass
Look back periodsint26lookbackperiod
Number of ATRs vs body massint1noOfAtr
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Raschke Patterns

by TradersPost
218 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy

Force Bar

by milocaetano
48 stars

Force Bar highlights candlesticks directly on the price chart using three distinct body and range criteria: widest range (Biggest), extreme body relative to historical average (Exhaustion), and moderate body relative to historical average (Force). Colors apply

Indicator v5 Candlestick patternsVolatility & bands
Updated yesterday · MIT GitHub repository of Force Bar

Zen Z Bars V1

by Zen-Tim
29 stars

Zen Z Bars V1 analyzes bar-by-bar price action, candle range expansion, and internal bar strength (IBS). It identifies breakouts, inside and outside bars, climax candles based on range expansion factors, and tiered range multiple bars. The indicator draws brea

Indicator v5 Candlestick patternsBreakout
Updated 2 weeks ago · MIT GitHub repository of Zen Z Bars V1
15 stars

This indicator plots Bollinger Bands and smoothed HAMA candles on the price chart. It builds each candle from separate moving averages of open, high, low and close, using selectable EMA, SMA or WMA lengths. A simple moving average forms the band basis, and an

Indicator v5 Candlestick patternsMoving averages
Updated 4 months ago · Apache-2.0 GitHub repository of NSDT HAMA Candles with Bollinger Bands

Calculates adaptive arithmetic candles by blending price data with Kaufman Efficiency Ratio smoothing and a linear regression anchor. It measures trend health using a zero-to-hundred Quality Score derived from market efficiency, regression slope, and normalize

Indicator v6 TrendCandlestick patterns
Updated yesterday · MIT GitHub repository of Adaptive Arithmetic Candles + Quality Score [WavesUnchained]

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers