Indicator · Pine Script v5 · Own pane

CSW Bull/Bear Force

by g-moe· code credited to goodgains

This indicator measures buyer and seller strength over a fixed twenty-bar lookback window and plots the result in a separate pane.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code57
Settings5inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 2026

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

57 lines of Pine Script v5 from Tradingview/csw-bull-bear-force.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

csw-bull-bear-force.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains

//@version=5
indicator(title='CSW Bull/Bear Force', overlay=false)

// @keywords: bull-force, bear-force, buyer-seller-strength, alma-direction, column-histogram, zero-line, pivot-window, highest-lowest, normalized-force, gradient-columns, direction-line, market-control, range-bound, swing-high-low, force-strength, lower-pane-oscillator, net-force, trend-direction, instruction-label, exponential-force

//--INSTRUCTIONS--//
instructions_tooltip = "• The Bull/Bear Forces shows the strength of buyers versus sellers in the market. 
 \nIf we see more green then buyers are in control. If we see more red then sellers are in control. 
  \nIf there is an even amount of buyers and sellers then the market is likely range bound or a trend is coming to an end."

instructions = input.bool(title='Show Instructions', defval=false, inline='1', tooltip = instructions_tooltip)
if barstate.islast and instructions
    var label instruction_label = na
    if not na(instruction_label[1])
        label.delete(instruction_label[1])
    instruction_label := label.new(bar_index + 5, close, instructions_tooltip, xloc = xloc.bar_index , yloc = yloc.price, color = color.black , style = label.style_label_left, textcolor = color.white, size = size.large, textalign = text.align_left) 
//--INSTRUCTIONS--//

color_up = input.color(#27a69b, title='Bull Increasing Color', inline='2', group='Visual Settings')
color_down = input.color(#b63632, title='Bear Increasing Color', inline='2', group='Visual Settings')
color_up2 = input.color(#5d606b, title='Bull Decreasing Color', inline='2', group='Visual Settings')
color_down2 = input.color(#5d606b, title='Bear Decreasing Color', inline='2', group='Visual Settings')
//smooth = input(title='Smoothing - ', type=input.bool, defval=false, inline = "3", group = "Indicator Settings")
//window = input.int(title=' Length:', defval=20, inline='3', group='Indicator Settings')
window = 20

f_exp_lr(_height, _length) =>
    _ret = _height + _height / _length
    _ret

h_value = ta.highest(close, window)
l_value = ta.lowest(close, window)
h_bar = ta.highestbars(close, window)
l_bar = ta.lowestbars(close, window)

normFactor = 100 / window

bear = 0 - (f_exp_lr(h_value - close, h_bar) > 0 ? f_exp_lr(h_value - close, h_bar) : 0)
bull = 0 + (f_exp_lr(close - l_value, l_bar) > 0 ? f_exp_lr(close - l_value, l_bar) : 0)

bull_avg = normFactor * bull
bear_avg = normFactor * bear

bull_color = color.from_gradient(bull_avg, ta.lowest(bull_avg, window), ta.highest(bull_avg, window), color_up2, color_up)
bear_color = color.from_gradient(bear_avg, ta.lowest(bear_avg, window), ta.highest(bear_avg, window), color_down, color_down2)

direction = ta.alma(bull_avg + bear_avg, 5, 0.9, 6)
dcolor = direction[0] > direction[1] ? color_up : direction[0] < direction[1] ? color_down : color.yellow

highs = plot(title='Bull Force', series=bull_avg, style=plot.style_columns, color=color.new(bull_color, 0))
lows = plot(title='Bear Force', series=bear_avg, style=plot.style_columns, color=color.new(bear_color, 0))
plot(title = "Direction Outline",series=direction, style=plot.style_line, linewidth=8, color= color.black)
plot(title='Direction', series=direction, style=plot.style_line, linewidth=2, color= dcolor)
plot(0, title='zero line', color=color.new(color.white, 30), linewidth=2)

Overview

CSW Bull/Bear Force calculates bull force based on the distance from the lowest close and bear force from the highest close, incorporating the bar distance of those extremes. Both forces are plotted as gradient-shaded histogram columns above and below a zero line. An Arnaud Legoux Moving Average (ALMA) smooths the net force into a direction line. Visual settings allow customization of bull and bear colors.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

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.

Settings

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

SettingTypeDefaultVariable
Show Instructionsboolfalseinstructions
Bull Increasing Colorcolor#27a69bcolor_up
Bear Increasing Colorcolor#b63632color_down
Bull Decreasing Colorcolor#5d606bcolor_up2
Bear Decreasing Colorcolor#5d606bcolor_down2
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

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

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