Indicator · Pine Script v6 · Own pane

Grid Bot Predictive Ranges [psyll]

by cullyk· code credited to Copyright

This indicator calculates predictive volatility boundaries and support/resistance range channels for grid trading configurations.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv6current
Lines of code66
Settings16inputs
LicenceMIT
Last update8 months ago25 Feb 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

66 lines of Pine Script v6 from plugins/Grid Bot [Grid range plugin] Predictive Ranges [psyll].pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Grid Bot [Grid range plugin] Predictive Ranges [psyll].pine
//@version=6
// Author: Psyll.com
// Email: info@psyll.com
// Website: https://psyll.com
// Copyright: Copyright © 2025 psyll.com. All rights reserved.
indicator('Grid Bot [Grid range plugin] Predictive Ranges [psyll]', overlay = false)
settings_group = '##### Settings'
length = input.int(200, 'Length', minval = 2, group = settings_group, display = display.none)
mult = input.float(12., 'Factor', minval = 0, step = .5, group = settings_group, display = display.none)
src = input(close, 'Source', group = settings_group, display = display.none)
level = input.int(2, title = 'Level', minval = 1, maxval = 2, group = settings_group, display = display.none)
offset = input.float(1, 'Offset', group = settings_group, display = display.none)
smooth = input.int(defval = 2, title = 'Smoothness', group = settings_group, display = display.none)
width_min = input.float(0, 'Min width', group = settings_group, display = display.none)
width_max = input.float(99999, 'Max width', group = settings_group, display = display.none)
width_min_half = width_min / 2
width_max_half = width_max / 2
tf_group = '##### Timeframe'
tf_confirmation_wait = input.bool(defval = true, title = 'Wait for confirm', group = tf_group, inline = tf_group, display = display.none)
tf_no_repaint_security = input.bool(defval = true, title = 'No repaint', group = tf_group, inline = tf_group, display = display.none)
tf_barmerge_lookahead = input.bool(defval = false, title = 'Lookahead', group = tf_group, inline = tf_group, display = display.none)
tf_barmerge_gaps = input.bool(defval = false, title = 'Gaps', group = tf_group, inline = tf_group, display = display.none)
tf_type = input.string(title = 'Type', options = ['Static', 'Custom'], defval = 'Static', group = tf_group, display = display.none)
tf_static = input.timeframe(defval = '', title = 'Static', group = tf_group, display = display.none)
tf_custom = str.tostring(input.int(1, 'Custom', group = tf_group, display = display.none))
tf_type_value = switch tf_type
    'Static' => tf_static
    'Custom' => tf_custom
tf_security(source) =>
    request.security(syminfo.tickerid, tf_type_value, tf_no_repaint_security ? source[barstate.isrealtime ? 1 : 0] : source, gaps = tf_barmerge_gaps ? barmerge.gaps_on : barmerge.gaps_off, lookahead = tf_barmerge_lookahead ? barmerge.lookahead_on : barmerge.lookahead_off)[tf_no_repaint_security ? barstate.isrealtime ? 0 : 1 : 0]
display_group = '##### Display'
price_color = input.color(color.black, 'Candles color', display = display.none, group = display_group)
plotcandle(open, high, low, close, color = price_color, bordercolor = price_color, wickcolor = price_color, display = display.pane)
grid_high = 0.0
grid_low = 0.0
ranges(length, mult) =>
    var avg = src
    var hold_atr = 0.
    atr = nz(tf_security(ta.atr(length))) * mult
    avg := src - avg > atr ? avg + atr : avg - src > atr ? avg - atr : avg
    hold_atr := avg != avg[1] ? atr / 2 : hold_atr
    [avg + hold_atr * 2, avg + hold_atr, avg, avg - hold_atr, avg - hold_atr * 2]
[prR2, prR1, avg, prS1, prS2] = ranges(length, mult)
if level == 1
    grid_high := prR1 + offset
    grid_low := prS1 - offset
    grid_low
if level == 2
    grid_high := prR2 + offset
    grid_low := prS2 - offset
    grid_low
grid_middle = (grid_high + grid_low) / 2
if grid_high - grid_low < width_min
    grid_high := grid_middle + width_min_half
    grid_low := grid_middle - width_min_half
    grid_low
if grid_high - grid_low > width_max
    grid_high := grid_middle - width_max_half
    grid_low := grid_middle + width_max_half
    grid_low
grid_middle := ta.sma(grid_middle, smooth)
grid_high := ta.sma(grid_high, smooth)
grid_low := ta.sma(grid_low, smooth)
plot(grid_high, 'High', color.green, display = display.all)
plot(grid_middle, 'Middle', color.silver, display = display.pane)
plot(grid_low, 'Low', color.red, display = display.all)

Overview

Grid Bot Predictive Ranges [psyll] determines grid envelopes using an ATR-based step algorithm across a configurable length and multiplier factor, with customizable offset and width constraints. Users can select between two boundary levels to tighten or expand the calculated range, and configure higher-timeframe security parameters to control repainting or lookahead behavior. The script displays price candles alongside the calculated grid levels in a separate indicator pane.

Details

Published by

cullyk on GitHub

Code credit

Copyright, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • 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
Lengthint200length
Factorfloat12.mult
Sourcesourceclosesrc
Levelint2level
Offsetfloat1offset
Smoothnessint2smooth
Min widthfloat0width_min
Max widthfloat99999width_max
Wait for confirmbooltruetf_confirmation_wait
No repaintbooltruetf_no_repaint_security
Lookaheadboolfalsetf_barmerge_lookahead
Gapsboolfalsetf_barmerge_gaps
Show all 16 settings
SettingTypeDefaultVariable
TypestringStatictf_type
Statictimeframetf_static
Customint1Custom
Candles colorcolorcolor.blackprice_color
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

CCI DC

by be-thomas
65 stars

This indicator plots the Commodity Channel Index in a separate pane and surrounds it with a Donchian channel whose lookback length changes with volatility. It measures volatility as a ratio of short and long ATR values, then ranks that ratio and shortens or le

Indicator v5 Oscillators & momentumVolatility & bands
Updated 6 days ago · GPL-3.0 GitHub repository of CCI DC

Trailing Drawdown

by palitojendthen
20 stars

The Trailing Drawdown indicator calculates and visualizes the percentage drop of a price series from its peak over a user-specified lookback period. It tracks maximum price levels within a rolling window and measures the current deviation from those peaks. Tra

Indicator v5 Volatility & bandsSupport & resistance
Updated 1 year ago · None stated GitHub repository of Trailing Drawdown

Market Pressure Scale plots two oscillator curves in a separate pane. Setup pressure combines ATR and Bollinger compression, support and resistance proximity, and drying volume. Impulse pressure combines range expansion, volume, and candle body size. A range-c

Indicator v6 Oscillators & momentumVolatility & bands
Updated 3 days ago · MIT GitHub repository of Market Pressure Scale [WavesUnchained]

QFA Pro Elite Refined

by JasonTeixeira
9 stars

This indicator plots a smoothed fear index in a separate pane. It measures how far the current low sits below the highest close over a lookback, scales that reading by an ATR percentile, and smooths it with a zero-lag EMA. A volatility regime raises or lowers

Indicator v6 Oscillators & momentumVolatility & bands
Updated 2 weeks ago · Custom licence GitHub repository of QFA Pro Elite Refined
7 stars

The Per Bak Self-Organized Criticality indicator calculates a composite fragility score by blending weights for tail risk from the SKEW index, volatility regimes from VIX terms, credit stress from HYG and LQD, and positioning from short volume data. It plots t

Indicator v5 Volatility & bandsSupport & resistance
Updated 3 months ago · None stated GitHub repository of Per Bak Self-Organized Criticality

MACD Breakout

by jerryinyang
5 stars

This indicator plots a higher-timeframe MACD breakout setup on the price chart and combines it with linear regression channels. It marks support and resistance zones from MACD histogram sensitivity, then filters them with the MACD zero line, a linear regressio

Indicator v4 Oscillators & momentumBreakout
Updated 2 years ago · None stated GitHub repository of MACD Breakout

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers