Indicator · Pine Script v6 · Own pane

CSI based on RSI, BB and Vol

by chaise-cogent

This indicator calculates a custom CSI value using price body ratio, volume score, and range z-score normalized by ATR.

View on GitHub

GitHub stars5on the repository
Pine versionv6current
Lines of code62
Settings5inputs
LicenceMIT
Last update7 months ago19 Mar 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

62 lines of Pine Script v6 from src/csi_rsi_bb_volume.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

csi_rsi_bb_volume.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Idea of negrbluad https://habr.com/ru/articles/934602/
// © chaise_cogent

//@version=6
indicator("CSI based on RSI, BB and Vol", overlay = false)

rsi_threshold = input.float(60, 'RSI % threshold')
csi_threshold = input.float(15, 'CSI % cut threshold')
csi_length = input.int(1, 'CSI MA length')
bb_length = input.int(14, 'Bollinger length')
bb_mult = input.float(1.8, 'Bollinger multiplicator', step = 0.1)

CSI_PERCENTILE_LENGTH = 100 // Why?
RSI_LENGTH = 450

calc_csi() =>
    _PRICE_LENGTH = 30 // Why?
    _VOLUME_LENGTH = 50 // Why?
    _ATR_LENGTH = 14 // Why?
    _body = math.abs(close - open)
    _height = high - low
    _height_na = _height == 0 ? na : _height
    _body_ratio = _body / _height_na
    _direction = close > open ? 1 : -1
    _volume_score = volume / ta.highest(volume, _VOLUME_LENGTH)
    _range_z_score = _height_na / ta.stdev(_height_na, _PRICE_LENGTH)
    _tr = math.max(_height, math.abs(high - close[1]), math.abs(low - close[1]))
    _atr = ta.median(_tr, _ATR_LENGTH)
    csi = _direction * (0.5 * _body_ratio + 0.3 * _volume_score + 0.2 * _range_z_score) / _atr

ind_rsi = ta.rsi(close, RSI_LENGTH)
ind_csi = ta.sma(calc_csi(), csi_length)
[ bb_mid, bb_upper, bb_lower ] = ta.bb(close, bb_length, bb_mult)

csi_bull_threshold = ta.percentile_nearest_rank(ind_csi, CSI_PERCENTILE_LENGTH, 100 - csi_threshold)
csi_bear_threshold = ta.percentile_nearest_rank(ind_csi, CSI_PERCENTILE_LENGTH, csi_threshold)

// Sentiments: Bull vs Bear
csi_bull_sentiment = ind_csi > 0 and ind_csi > csi_bull_threshold and ind_csi > ind_csi[1]
csi_bear_sentiment = ind_csi < 0 and ind_csi < csi_bear_threshold and ind_csi < ind_csi[1]

rsi_bull_sentiment = ind_rsi < rsi_threshold
rsi_bear_sentiment = ind_rsi > (100 - rsi_threshold)

bb_bull_sentiment = close < bb_lower
bb_bear_sentiment = close > bb_upper

// Result
is_bull = bb_bull_sentiment and csi_bull_sentiment and rsi_bull_sentiment
is_bear = bb_bear_sentiment and csi_bear_sentiment and rsi_bear_sentiment

// Indicator and Bollinger Bands
plotshape(is_bull, style=shape.triangleup, color = color.green, location = location.belowbar, size = size.small, force_overlay = true, title = 'Long')
plotshape(is_bear, style=shape.triangledown, color = color.red, location = location.abovebar, size = size.small, force_overlay = true, title = 'Short')
plot(bb_lower, color=color.new(color.green, 40), force_overlay = true, title = 'Bollinger lower')
plot(bb_upper, color=color.new(color.red, 40), force_overlay = true, title = 'Bollinger higher')

// CSI
plot(ind_csi, title = 'CSI')
plot(csi_bull_threshold, title = 'CSI high threshold', color = color.red)
plot(csi_bear_threshold, title = 'CSI low threshold', color = color.green)

Overview

CSI based on RSI, BB and Vol generates bull and bear sentiment signals when CSI, RSI below 60, and Bollinger Band conditions align simultaneously. Bull signals trigger green triangle markers below the bar and bear signals trigger red triangles above the bar. The CSI line, upper and lower thresholds, and Bollinger Bands are plotted in a separate pane. Settings control RSI threshold, CSI percentile cutoff, CSI smoothing length, Bollinger length, and multiplier. No stop loss or position sizing is applied.

Details

Published by

chaise-cogent on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Volume

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
RSI % thresholdfloat60rsi_threshold
CSI % cut thresholdfloat15csi_threshold
CSI MA lengthint1csi_length
Bollinger lengthint14bb_length
Bollinger multiplicatorfloat1.8bb_mult
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

114 stars

This indicator standardizes price inputs using z-score normalization before calculating a relative strength index (RSI). It generates trade signals when standardized price components cross over or under the standardized RSI feature. Signals can be filtered by

Indicator v4 Oscillators & momentumVolatility & bands Repaints
Updated 1 year ago · None stated GitHub repository of Preprosessed & Standardized RSI

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

This indicator calculates the Relative Strength Index (RSI) alongside a simple moving average to generate directional momentum signals in a separate pane. It supports Break Flip and Break Continuous scanning modes for long and short setups. A wide array of opt

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of Momentum Setup: RSI Direction Confirmation

NFI v6

by koradiyakaushal
12 stars

This Pine v4 study ports early NostalgiaForInfinity V6 conditions onto the price chart. It computes two Bollinger setups, several EMAs and SMAs, RSI, MFI, a percent SMA spread labeled EWO, a 14-period choppiness value, and short and longer volume medians. Fixe

Indicator v4 Moving averagesVolatility & bands
Updated 5 years ago · MIT GitHub repository of NFI v6

The script calculates a variant of the Fear & Greed Index using rate of return, accumulation distribution money flow weighted by volume, and volatility from VIX. It offers display options for the raw index value or price candles scaled by the index level. Smoo

Indicator v5 Oscillators & momentumVolatility & bands Repaints
Updated 4 years ago · MPL-2.0 GitHub repository of Trading Psychology - Fear & Greed Index by DGT

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