Indicator · Pine Script v5 · On the chart

CSW MTF Sentiment Line

by g-moe· code credited to goodgains

CSW MTF Sentiment Line evaluates market sentiment across five customizable timeframes on the price chart.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code126
Settings12inputs
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

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

csw-mtf-sentiment-line.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('CSW MTF Sentiment Line', overlay=true, scale=scale.none, max_lines_count=500, max_labels_count=500)

// @keywords: csw-mtf-sentiment, multi-timeframe, rsi-sentiment, volatility-sentiment, volume-sentiment, sentiment-score, overbought-oversold, gradient-scale, timeframe-labels, mtf-panel, sentiment-line, normalized-reading, scale-lines, sentiment-rating, five-timeframes, oscillator-sentiment, sentiment-dashboard, optional-instructions, bar-offset-display, aggregate-average

//--INSTRUCTIONS--//
instructions_tooltip = "• The CSW MTF Sentiment Line is very similar to the CSW Sentiment Line. However instead of plotting RSI, Volatility, 
 \nand Volume, the user can select one option. That one option then gets a sentiment rating on five different user-selectable timeframes. 
 \nThe Sentiment Line rates RSI, Volatility, and Volume from 0 to 100. Values closer to 100 means it is overbought or a strong reading. 
 \nValues closer to 0 mean it is oversold or a weak reading. The Sentiment Line is just an add-on tool for your chart for a quick glance
 \nto see where RSI, Volatility, and Volume are at for the current chart symbol."

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--//

type = input.string('RSI', title = 'Type', options = ['RSI', 'Volatility', 'Volume'])
length = input.int(14, title = 'Length')

tf1 = input.timeframe("", title = "Timeframe 1", inline = '2')
tf2 = input.timeframe("60", title = "Timeframe 2", inline = '3')
tf3 = input.timeframe("240", title = "Timeframe 3", inline = '4')
tf4 = input.timeframe("D", title = "Timeframe 4", inline = '5')
tf5 = input.timeframe("W", title = "Timeframe 5", inline = '6')

color_up = input.color(color.new(#27a69b,30), title='Bull Color', inline='1', group='Visual Settings')
color_down = input.color(color.new(#b63632,30), title='Bear Color', inline='1', group='Visual Settings')
label_color = input.color(#ffffff, title = 'Label Color', inline='1', group='Visual Settings')

offset = input.int(150, 'Line Offset', group='Visual Settings', minval = 0, maxval = 500)

n = bar_index
var names = array.new_string(0)
var values = array.new_float(0)
var scale_lines = array.new_line(0)
dt = math.round(n - n[1])

rsi(tf, length) =>
    value1 = request.security(syminfo.tickerid, tf, ta.rsi(close,length) / 100, lookahead = barmerge.lookahead_on)
    value1
    
vol(tf, length) =>
    value1 = request.security(syminfo.tickerid, tf, ta.rsi(ta.stdev(close, 30),length) / 100, lookahead = barmerge.lookahead_on)
    value1

volume_f(tf, length) =>
    value1 = request.security(syminfo.tickerid, tf, ta.rsi(ta.sma(volume,20),length) / 100, lookahead = barmerge.lookahead_on)
    value1
    
var value1 = 0.00
var value2 = 0.00
var value3 = 0.00
var value4 = 0.00
var value5 = 0.00
 
if type == 'RSI'
    value1 := rsi(tf1, length)
    value2 := rsi(tf2, length)
    value3 := rsi(tf3, length)
    value4 := rsi(tf4, length)
    value5 := rsi(tf5, length)
    
if type == 'Volatility'
    value1 := vol(tf1, length)
    value2 := vol(tf2, length)
    value3 := vol(tf3, length)
    value4 := vol(tf4, length)
    value5 := vol(tf5, length)
    
if type == 'Volume'
    value1 := volume_f(tf1, length)
    value2 := volume_f(tf2, length)
    value3 := volume_f(tf3, length)
    value4 := volume_f(tf4, length)
    value5 := volume_f(tf5, length)

if barstate.isfirst
    for i = 0 to 99 by 1
        array.push(scale_lines, line.new(na, na, na, na))

if barstate.islast
    array.push(values, value1)
    array.push(values, value2)
    array.push(values, value3)
    array.push(values, value4)
    array.push(values, value5)
    array.push(values, array.get(values, 0))

    avg = (array.avg(values) - .5) * 2
    avg_css = color.from_gradient(avg, -1.2, 1.2, color_down, color_up)

    tf1_text = tf1 == "" ? str.tostring(timeframe.period) : tf1
    tf2_text = tf2 == "" ? str.tostring(timeframe.period) : tf2
    tf3_text = tf3 == "" ? str.tostring(timeframe.period) : tf3
    tf4_text = tf4 == "" ? str.tostring(timeframe.period) : tf4
    tf5_text = tf5 == "" ? str.tostring(timeframe.period) : tf5
    
    label.delete(label.new(n + offset , (value1 - .5) * 2, "  " + str.tostring(math.round(value1*100,2)) + "-" + type + "  " + tf1_text , color = #00000000, style = label.style_label_left, textcolor = label_color, textalign = text.align_right)[1])
    label.delete(label.new(n + offset, (value2 - .5) * 2, "  " + str.tostring(math.round(value2*100,2)) + "-" + type + "  " + tf2_text , color = #00000000, style = label.style_label_left, textcolor = label_color, textalign = text.align_right)[1])
    label.delete(label.new(n + offset, (value3 - .5) * 2, "  " + str.tostring(math.round(value3*100,2)) + "-" + type + "  " + tf3_text , color = #00000000, style = label.style_label_left, textcolor = label_color, textalign = text.align_right)[1])
    label.delete(label.new(n + offset, (value4 - .5) * 2, "  " + str.tostring(math.round(value4*100,2)) + "-" + type + "  " + tf4_text , color = #00000000, style = label.style_label_left, textcolor = label_color, textalign = text.align_right)[1])
    label.delete(label.new(n + offset, (value5 - .5) * 2, "  " + str.tostring(math.round(value5*100,2)) + "-" + type + "  " + tf5_text , color = #00000000, style = label.style_label_left, textcolor = label_color, textalign = text.align_right)[1])
    
    for i = 1 to 99 by 1
        y1 = ((i - 1) / 99 - .5) * 2
        y2 = (i / 99 - .5) * 2

        css = color.from_gradient(i, 1, 100, color_down, color_up)
        scale_line = array.get(scale_lines, i)
        line.set_xloc(scale_line, n + dt * offset + dt , bar_index + dt * offset + dt, xloc.bar_index)
        line.set_y1(scale_line, y1)
        line.set_y2(scale_line, y2)
        line.set_width(scale_line, 8)
        line.set_color(scale_line, css)

    label.delete(label.new(n + offset, 1.025, '100', xloc.bar_index, yloc.price, color=#00000000, style=label.style_label_center, textcolor=color_up, textalign=text.align_center)[1])
    label.delete(label.new(n + offset, -1.025, '0', xloc.bar_index, yloc.price, color=#00000000, style=label.style_label_center, textcolor=color_down, textalign=text.align_center)[1])
    label.delete(label.new(n + offset, 1.1, '� CSW ' + type + ' Sentiment', xloc.bar_index, yloc.price, color=#00000000, style=label.style_label_center, textcolor=label_color, textalign=text.align_center)[1])

Overview

Traded assets can be measured using RSI, volatility (RSI of price standard deviation), or volume (RSI of volume moving average), with values normalized on a 0 to 100 scale. Visual scale lines and labels are projected to the right of current bars. Higher-timeframe calculations use lookahead mode, causing historical values to repaint.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Volatility & bands, Volume, Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
Show Instructionsboolfalseinstructions
TypestringRSItype
Lengthint14length
Timeframe 1timeframetf1
Timeframe 2timeframe60tf2
Timeframe 3timeframe240tf3
Timeframe 4timeframeDtf4
Timeframe 5timeframeWtf5
Bull Colorcolorcolor.new(#27a69b,30)color_up
Bear Colorcolorcolor.new(#b63632,30)color_down
Label Colorcolor#fffffflabel_color
Line Offsetint150offset
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

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

DEPV2 Debug Siga

by YuceSezar89
1 stars

DEPV2 is a multi-symbol crypto indicator that generates trading signals across 20 Binance assets including BTC, ETH, and SOL. It analyzes four method classes—trend, momentum, volatility, and volume—using modes such as simultaneous confirmation requiring at lea

Indicator v6 Screeners & dashboardsOscillators & momentum Repaints
Updated 11 days ago · None stated GitHub repository of DEPV2 Debug Siga

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

This multi-symbol indicator evaluates a combined trading condition across up to 40 user-defined symbols. It processes MACD bullish crossovers, RSI thresholds, Bollinger Band boundaries, and DMI/ADX trend filters using security calls. When buy or sell criteria

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Multi MACD + BB + RSI [Alorse]

LiqSpikeBounceLong Feb2026

by agutinbaigo28
147 stars

LiqSpikeBounceLong Feb2026 is an indicator designed to identify long bounce entries following high-volume liquidation cascades in bearish market contexts. It checks if price is below an exponential moving average, then detects large single-bar drops exceeding

Indicator v5 Volatility & bandsVolume
Updated 6 weeks ago · MIT GitHub repository of LiqSpikeBounceLong Feb2026

8zz反指標v2

by hansai-art
121 stars

The 8zz Contrarian Indicator plots reverse sentiment trading signals directly on the price chart based on tracked retail post activity. It generates bullish signals during retail panic and bearish signals during market euphoria. The indicator features adjustab

Indicator v6 Moving averagesOscillators & momentum
Updated 3 months ago · None stated GitHub repository of 8zz反指標v2

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