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.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
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.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
length
int
50
length
Standart Deviation
float
3.0
sd
+
color
color.rgb(0, 251, 222)
plus
-
color
color.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.
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
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
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
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
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
Calculates mean reversion signals using statistical deviation metrics such as MAD, Standard Deviation, ATR, Z-Score, IQR, or Mean AD relative to customizable moving averages. It applies optional volume spike thresholds and trend filters to generate bullish and