Indicator · Pine Script v5 · Own pane

Grid Bot Direction Plugin Supertrend Pivot psyll

by cullyk· code credited to Copyright

The Grid Bot Direction Plugin Supertrend Pivot indicator calculates dynamic market trend direction for automated grid trading.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code52
Settings10inputs
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

52 lines of Pine Script v5 from plugins/Grid Bot [Direction plugin] Supertrend Pivot [psyll].pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Grid Bot [Direction plugin] Supertrend Pivot [psyll].pine
//@version=5
// Author: Psyll.com
// Email: info@psyll.com
// Website: https://psyll.com
// Copyright: Copyright © 2025 psyll.com. All rights reserved.
indicator('Grid Bot [Direction plugin] Supertrend Pivot [psyll]', overlay=false)
prd = input.int(defval=20, title='Pivot Point Period', minval=1, maxval=999, display = display.none)
Factor = input.float(defval=3, title='ATR Factor', minval=1, step=0.1, display = display.none)
Pd = input.int(defval=14, title='ATR Period', minval=1, display = display.none)
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]
float ph = tf_security(ta.pivothigh(prd, prd))
float pl = tf_security(ta.pivotlow(prd, prd))
var float center = na
float lastpp = ph ? ph : pl ? pl : na
if lastpp
    if na(center)
        center := lastpp
        center
    else
        center := (center * 2 + lastpp) / 3
        center

Up = center - Factor * tf_security(ta.atr(Pd))
Dn = center + Factor * tf_security(ta.atr(Pd))
float TUp = na
float TDown = na
Trend = 0
TUp := close[1] > TUp[1] ? math.max(Up, TUp[1]) : Up
TDown := close[1] < TDown[1] ? math.min(Dn, TDown[1]) : Dn
Trend := close > TDown[1] ? 1 : close < TUp[1] ? -1 : nz(Trend[1], 1)
Trailingsl = Trend == 1 ? TUp : TDown
linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.lime : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na
plot(Trailingsl, color=linecolor, linewidth=2, title='Plot', display = display.pane)
bsignal = Trend == 1 and Trend[1] == -1
ssignal = Trend == -1 and Trend[1] == 1
float resistance = na
float support = na
support := pl ? pl : support[1]
resistance := ph ? ph : resistance[1]
plot(Trend == 1 and nz(Trend[1]) == 1 ? 1 : Trend == -1 and nz(Trend[1]) == -1 ? -1 : na, "Direction", display = display.status_line)

Overview

Grid Bot Direction Plugin Supertrend Pivot psyll computes a smoothed center level derived from pivot highs and lows, combining it with ATR-based bands to generate a trailing stop line similar to a Supertrend indicator. The script features configurable multi-timeframe security settings, allowing users to select static or custom timeframes with options to adjust repaint and lookahead behavior. It plots the trailing stop level and direction signal in a separate 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
Pivot Point Periodint20prd
ATR Factorfloat3Factor
ATR Periodint14Pd
Wait for confirmbooltruetf_confirmation_wait
No repaintbooltruetf_no_repaint_security
Lookaheadboolfalsetf_barmerge_lookahead
Gapsboolfalsetf_barmerge_gaps
TypestringStatictf_type
Statictimeframetf_static
Customint1Custom
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

SuperTrend

by SiegerTerpstra
5 stars

This indicator calculates and plots dynamic SuperTrend volatility bands around median price to identify market trend direction. It signals bullish conditions when price stays above the green support line and bearish conditions when price falls below the red re

Indicator v6 TrendVolatility & bands
Updated 9 months ago · None stated GitHub repository of SuperTrend
4 stars

This indicator is a live strategy scanner for cryptocurrency pairs. It runs six strategies on the current chart, tracks their wins and losses, and rates them to show the best one for this pair and timeframe. It uses ATR for adaptive TP/SL, auto-scales based on

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 days ago · None stated GitHub repository of Crypto Pair Selector v2 STEPFUN
2 stars

This indicator tracks market direction by combining Bollinger Bands breakouts with ATR-adjusted pivot point channels. It establishes a primary trend line based on price breaking outer Bollinger Bands filtered by ATR, then validates the movement with a secondar

Indicator v4 TrendVolatility & bands
Updated 5 years ago · None stated GitHub repository of DeFi Follow Line Trend Signal

The Keltner Center Of Gravity Channel Mutations Indicator calculates adaptive channel metrics based on Donchian range Fibonacci levels (38.2% and 61.8%) and Average True Range (ATR) offsets. The lookback period automatically adjusts according to the active tim

Indicator v5 Volatility & bandsVolume
Updated 8 months ago · None stated GitHub repository of Keltner Center Of Gravity Channel Mutations Indicator

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

More Trend 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