Indicator Β· Pine Script v6 Β· On the chart

fungi Bands [aifungi]

by mushroom-men-Trading

This indicator draws three bands on the price chart from the highest and lowest prices over a chosen length, expanded by a long ATR times a deviation setting.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code124
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update9 months ago25 Jan 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

124 lines of Pine Script v6 from Indicators/indicators/DNA Made/dna bands.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

dna bands.pine
// This Pine Scriptβ„’ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// @ cander

//@version=6
indicator('fungi Bands [aifungi]', 'dnaBand', overlay = true)


// --------------------------------------------------------------------------------------------------------------------}
// π™π™Žπ™€π™ π™„π™‰π™‹π™π™π™Ž
// --------------------------------------------------------------------------------------------------------------------{
int length = input.int(50)
float sd = input.float(3.0, title = 'Standart Deviation', minval = 0.1, step = 0.1)

// Colors
color plus = input.color(color.rgb(0, 251, 222), '+', inline = 'Color')
color minus = input.color(color.rgb(106, 0, 255), '-', inline = 'Color')


// --------------------------------------------------------------------------------------------------------------------}
// π™„π™‰π˜Ώπ™„π˜Ύπ˜Όπ™π™Šπ™ π˜Ύπ˜Όπ™‡π˜Ύπ™π™‡π˜Όπ™π™„π™Šπ™‰π™Ž
// --------------------------------------------------------------------------------------------------------------------{

method check_size(array<float> array, val, size) =>
    array.push(array, val)
    if array.size(array) >= size
        array.shift(array)

label_plot(src, sd, col = chart.fg_color) =>
    txt = sd == 0 ? str.tostring(sd, '#') + ' ' : sd == 3 ? str.tostring(sd, '+#') + ' SD ' : str.tostring(sd, '#') + ' SD '

    label.delete(label.new(bar_index + 15, src, txt + str.tostring(src, '(#,###.##)'), style = label.style_label_left, color = color(na), textcolor = col)[1])

method line_new(float src, slope, color = chart.fg_color, width = 1) =>
    line.delete(line.new(bar_index, src, bar_index + 15, src + slope, width = width, color = color)[1])

slope(src) =>
    src - src[2]

mean_reversion(src, mid, lower, upper) =>
    float source = src - mid
    float mean_rev = (src - lower) / (upper - lower)

    mean_rev := ta.hma(mean_rev / ta.stdev(mean_rev, 200), 15) - 1
    mean_rev := math.min(4, math.max(-4, mean_rev))
    mean_rev


prime_bands(length) =>
    var upper = array.new<float>()
    var lower = array.new<float>()
    var color = color(na)

    float Hg = ta.highest(length)
    float Lw = ta.lowest(length)
    float base = math.avg(Hg, Lw)
    float atr = ta.atr(200)
    float up_b = base + atr * sd
    float low_b = base - atr * sd

    upper.check_size(up_b, length)
    lower.check_size(low_b, length)

    float up_band = ta.sma(upper.max(), 15)
    float low_band = ta.sma(lower.min(), 15)
    float mid_band = math.avg(up_band, low_band)
    float slope1 = slope(mid_band)
    float slope2 = slope(up_band)
    float slope3 = slope(low_band)

    float mean_rev = mean_reversion(hl2, mid_band, low_band, up_band)

    bool sig_down = ta.crossunder(mean_rev, mean_rev[1]) and high > up_band and mean_rev > ta.highest(mean_rev, length)[10]

    bool sig_up = ta.crossover(mean_rev, mean_rev[1]) and low < low_band and mean_rev < ta.lowest(mean_rev, length)[10]

    if ta.crossover(mid_band, mid_band[1])
        color := plus
        color
    if ta.crossunder(mid_band, mid_band[1])
        color := minus
        color

    if barstate.islast
        line_new(mid_band, slope1, color, 2)
        line_new(up_band, slope2)
        line_new(low_band, slope3)

        label_plot(up_band + slope2, +sd)
        label_plot(low_band + slope3, -sd)
        label_plot(mid_band + slope1, 0, color)

    [up_band, mid_band, low_band, color, sig_down, sig_up, mean_rev]


[up_band, mid_band, low_band, color, sig_down, sig_up, mean_rev] = prime_bands(length)


// --------------------------------------------------------------------------------------------------------------------}
// π™‘π™„π™Žπ™π˜Όπ™‡π™„π™•π˜Όπ™π™„π™Šπ™‰
// --------------------------------------------------------------------------------------------------------------------{
   
ph = plot(up_band, color = chart.fg_color)
pm = plot(mid_band, color = color, linewidth = 2)
pl = plot(low_band, color = chart.fg_color)

fill(pm, ph, up_band, mid_band, na, color.new(color, 90))
fill(pm, pl, mid_band, low_band, color.new(color, 90), na)

plotchar(sig_up, 'Signal Up', 'πŸ‘οΈ', location.belowbar, color = plus, size = size.tiny)
plotchar(sig_down, 'Signal Dn', 'πŸ‘οΈ', location.abovebar, color = minus, size = size.tiny)

if barstate.islast
    var tbl = table.new(position.middle_right, 100, 100)
    for i = 0 to 9 by 1
        tbl.cell(1, i + 1, bgcolor = color.from_gradient(i, 0, 8, minus, plus))
        tbl.cell(0, i + 1, 'β†ͺβ†ͺ', text_color = color(na))

        tbl.cell(0, 9 - math.round((hl2 > up_band ? 4 : hl2 < low_band ? -4 : mean_rev) + 4), 'β†ͺβ†ͺ', text_color = color.from_gradient(i, 0, 8, minus, plus))
        if i == 9
            tbl.cell(1, 9 + 1, str.tostring(-sd) + '\nSD', text_color = chart.fg_color)
        else if i == 0
            tbl.cell(1, 0, 'SD\n' + str.tostring(sd), text_color = chart.fg_color)

// --------------------------------------------------------------------------------------------------------------------}

Overview

fungi Bands [aifungi] smooths the stored extremes into upper and lower bands and an average midpoint, then changes the midpoint color when its direction turns. A bounded mean-reversion value flags turn conditions when price is outside a band. On the last bar it projects short slope lines and value labels. It does not place trades.

Details

Published by

mushroom-men-Trading on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Mean reversion

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
lengthint50length
Standart Deviationfloat3.0sd
+colorcolor.rgb(0, 251, 222)plus
-colorcolor.rgb(106, 0, 255)minus
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 plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago Β· None stated GitHub repository of Bollinger Bands Winner IND [Alorse]

TylerG FVG BB Reversal

by TradersPost
218 stars

This indicator identifies mean-reversion setups by combining Bollinger Bands with Fair Value Gaps (FVGs). It tracks FVGs that print outside the upper or lower Bollinger Bands and counts them toward an alert threshold. Signals trigger upon gap mitigation (by to

Indicator v6 SMC / ICT / price actionVolatility & bands
Updated 3 months ago Β· None stated GitHub repository of TylerG FVG BB Reversal
147 stars

This indicator combines Bollinger Bands, RSI, Stochastic RSI, and volume spike detection to identify mean-reversion conditions during range-bound market regimes. It calculates Bollinger Band width to identify low-volatility states and triggers buy or sell sign

Indicator v5 Oscillators & momentumVolatility & bands
Updated 6 weeks ago Β· MIT GitHub repository of BTC Dec 2025 β€” Range + Gamma Flush

Bollinger Bands

by be-thomas
65 stars

This indicator plots standard Bollinger Bands directly on the price chart using hardcoded settings of a 5-period length and a 4 standard deviation multiplier. It displays the middle basis line in blue, the upper and lower outer bands in green, and fills the ch

Indicator v4 Volatility & bandsMean reversion
Updated 4 days ago Β· GPL-3.0 GitHub repository of Bollinger Bands
55 stars

This Pine Script indicator overlays institutional liquidity levels on the price chart. It identifies order block levels using pivot highs and lows, then draws mean reversion lines from the 20 and 50 period simple moving averages, a volatility range midpoint pr

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
Updated 6 months ago Β· Apache-2.0 GitHub repository of AAPL Institutional Liquidity Grid

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