Indicator · Pine Script v5 · Own pane

TB: Auxiliary Indicators

by farias-hecdin

This indicator bundles several oscillators into one separate pane: an RSI drawn as circles with bands at 20, 45, 50, 55 and 80, a smoothed Stochastic with %K and %D, and a MACD with line, signal and area histogram.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code118
Settings19inputs
LicenceMIT
Last update1 year ago9 Feb 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

118 lines of Pine Script v5 from tb-auxiliary-indicators.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

tb-auxiliary-indicators.pine
// @version=5
// Last update: 28-ene-2025

indicator(title="TB: Auxiliary-indicators", shorttitle="TB-A", format=format.price, precision=2)


// RSI (Relative Strength Index) ----------------------------------------------

len = input.int(14, minval=1, title="Length", group="RSI")
srcZ = input.source(close, title="Source", group="RSI")
up = ta.rma(math.max(ta.change(srcZ), 0), len)
down = ta.rma(-math.min(ta.change(srcZ), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

plot(rsi, "RSI - line", color=color.new(color.yellow, 0), style=plot.style_circles)
band1  = hline(80, "RSI - upper", color=color.new(color.orange, 0), linestyle=hline.style_solid)
band0  = hline(20, "RSI - lower", color=color.new(color.blue, 0), linestyle=hline.style_solid)
banda1 = hline(50, "RSI - medium", color=color.new(color.white, 0))
banda3 = hline(55, "RSI - band", color=color.new(color.orange, 0), linestyle=hline.style_dotted)
banda4 = hline(45, "RSI - band", color=color.new(color.blue, 0), linestyle=hline.style_dotted)


// Stochastic -----------------------------------------------------------------

periodK = input.int(14, title="%K length", minval=1, group="Stoch")
smoothK = input.int(6, title="%K smoothing", minval=1, group="Stoch")
periodD = input.int(3, title="%D smoothing", minval=1, group="Stoch")
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

plot(k, title="Stoch - %K", color=color.new(color.blue, 0))
plot(d, title="Stoch - %D", color=color.new(color.orange, 0))
h0 = hline(80, "Stoch - upper band", color=color.new(color.gray, 0), linestyle=hline.style_dotted)
h1 = hline(20, "Stoch - lower band", color=color.new(color.gray, 0), linestyle=hline.style_dotted)
fill(h0, h1, color=color.rgb(49, 27, 146, 95), title="Stoch - background")


// MACD Crossover -------------------------------------------------------------

fast_length = input.int(title="Fast length", defval=12, group="MACD")
slow_length = input.int(title="Slow length", defval=26, group="MACD")
srcX = input.source(title="Source", defval=close, group="MACD")
signal_length = input.int(title="Signal smoothing", minval=1, maxval=50, defval=9, group="MACD")
sma_source = input.bool(title="Simple MA, oscillator", defval=false, group="MACD")
sma_signal = input.bool(title="Simple MA, signal line", defval=false, group="MACD")
fast_ma = sma_source ? ta.sma(srcX, fast_length) : ta.ema(srcX, fast_length)
slow_ma = sma_source ? ta.sma(srcX, slow_length) : ta.ema(srcX, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal

col_grow_above = color.new(color.teal, 0)
col_grow_below = color.new(color.gray, 0)
col_fall_below = color.new(color.red, 0)
col_fall_above = color.new(color.gray, 0)
col_macd = color.new(color.blue, 0)
col_signal = color.new(color.orange, 0)
col_level = color.new(color.white, 0)
hline(0, title="MACD - level", color=col_level, linewidth=1)
plot(hist, title="MACD - histogram", style=plot.style_area, color=(hist >= 0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
plot(macd, title="MACD - MACD line", color=col_macd, linewidth=2)
plot(signal, title="MACD - signal line", color=col_signal, linewidth=2)
barcolor(hist <= 0 ? color.new(color.red, 0) : hist >= 0 ? color.new(color.green, 0) : color.new(color.rgb(42, 46, 57, 0), 0), title="MACD (Bar color)")


// Absolute Strength Histogram ------------------------------------------------

Length = input.int(9, title="Period of evaluation [16, 9]", group="ASH")
Smooth = input.int(3, title="Period of smoothing [4, 3]", group="ASH")
src = input.source(close, title="Source", group="ASH")
Mode = input.string(title="Indicator method", defval="RSI", options=["RSI", "STOCHASTIC", "ADX"], group="ASH")
ma_type = input.string(title="Moving average", defval="EMA", options=["ALMA", "EMA", "WMA", "SMA", "SMMA", "HMA"], group="ASH")
alma_offset = input.float(defval=0.85, title="Offset value *[ALMA only]", minval=0, step=0.01, group="ASH")
alma_sigma = input.int(defval=6, title="Sigma value *[ALMA only]", minval=0, group="ASH")
show_histo = input.bool(true, title="Show histogram", group="ASH")

ma(type, src, len) =>
    float result = 0
    if type == "SMA"  // Simple
        result := ta.sma(src, len)
    if type == "EMA"  // Exponential
        result := ta.ema(src, len)
    if type == "WMA"  // Weighted
        result := ta.wma(src, len)
    if type == "SMMA"  // Smoothed
        w = ta.wma(src, len)
        result := na(w[1]) ? ta.sma(src, len) : (w[1] * (len - 1) + src) / len
    if type == "HMA"  // Hull
        result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))
    if type == "ALMA"  // Arnaud Legoux
        result := ta.alma(src, len, alma_offset, alma_sigma)
    result

Price = src
Price1 = ma("SMA", Price, 1)
Price2 = ma("SMA", Price[1], 1)

// RSI
Bulls0 = 0.5 * (math.abs(Price1 - Price2) + (Price1 - Price2))
Bears0 = 0.5 * (math.abs(Price1 - Price2) - (Price1 - Price2))

// STOCHASTIC
Bulls1 = Price1 - ta.lowest(Price1, Length)
Bears1 = ta.highest(Price1, Length) - Price1

// ADX
Bulls2 = 0.5 * (math.abs(high - high[1]) + (high - high[1]))
Bears2 = 0.5 * (math.abs(low[1] - low) + (low[1] - low))
Bulls = Mode == "RSI" ? Bulls0 : Mode == "STOCHASTIC" ? Bulls1 : Bulls2
Bears = Mode == "RSI" ? Bears0 : Mode == "STOCHASTIC" ? Bears1 : Bears2
AvgBulls = ma(ma_type, Bulls, Length)
AvgBears = ma(ma_type, Bears, Length)
SmthBulls = ma(ma_type, AvgBulls, Smooth)
SmthBears = ma(ma_type, AvgBears, Smooth)
difference = math.abs(SmthBulls - SmthBears)
difference_color = difference > SmthBulls ? ((SmthBears < SmthBears[1]) ? color.new(color.red, 0) : color.new(color.red, 0)) : difference > SmthBears ? ((SmthBulls < SmthBulls[1]) ? color.new(color.yellow, 0) : color.new(color.yellow, 0)) : color.new(color.rgb(19, 23, 34, 0), 0)

plot(difference, style=plot.style_histogram, linewidth=3, color=show_histo ? difference_color : na, title="ASH - Strength")

Overview

Further sections, such as an absolute strength histogram, are driven by a mode and moving average type setting. Each module has its own lengths and sources, and bars are coloured by the MACD histogram sign. Part of the code was not shown.

Details

Published by

farias-hecdin on GitHub

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum

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

pinescript

Settings

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

SettingTypeDefaultVariable
Lengthint14len
SourcesourceclosesrcZ
%K lengthint14periodK
%K smoothingint6smoothK
%D smoothingint3periodD
Fast lengthint12fast_length
Slow lengthint26slow_length
SourcesourceclosesrcX
Signal smoothingint9signal_length
Simple MA, oscillatorboolfalsesma_source
Simple MA, signal lineboolfalsesma_signal
Period of evaluation [16, 9]int9Length
Show all 19 settings
SettingTypeDefaultVariable
Period of smoothing [4, 3]int3Smooth
Sourcesourceclosesrc
Indicator methodstringRSIMode
Moving averagestringEMAma_type
Offset value *[ALMA only]float0.85alma_offset
Sigma value *[ALMA only]int6alma_sigma
Show histogrambooltrueshow_histo
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

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 11 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator

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
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

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