Indicator · Pine Script v5 · On the chart

Gary - Levels

by g-moe· code credited to goodgains

Gary - Levels is a TradingView Pine Script v5 indicator that overlays multiple session-based VWAP calculations and high/low lines directly on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code121
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

121 lines of Pine Script v5 from Tradingview/gary-levels.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

gary-levels.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("Gary - Levels", overlay = true)

// @keywords: session-vwap, rth-vwap, full-session-vwap, overnight-high-low, rth-session-lines, session-background, custom-vwap-calc, ny-session-times, extending-session-lines, multi-session-overlay, fs-vwap-trend, overnight-range, rth-range-box, equity-session-markers, anchored-vwap-periods, time-based-vwap-reset, line-extension, session-highlighting, institutional-levels, market-hours-zones


// rth vwap settings
use_rth_vwap    = input.bool(true, title = 'RTH VWAP', group = 'RTH VWAP', inline = '1')
rth_vwap_sess   = input.session('0930-1600', title = '', group = 'RTH VWAP', inline = '1')


// vwap settings
use_fs_vwap     = input.bool(true, title = 'FS VWAP', group = 'VWAP', inline = '1')
fs_vwap_sess    = input.session('1600-1559', title = '', group = 'VWAP', inline = '1')


// on lines
use_on          = input.bool(true, title = 'ON Lines/Labels', group = 'Overnight', inline = '1')
on_sess         = input.session('1800-0930', title = '', group = 'Overnight', inline = '1')

// rth lines
use_rth         = input.bool(true, title = 'RTH Lines/Labels', group = 'RTH', inline = '1')
rth_sess        = input.session('0930-1600', title = '', group = 'RTH', inline = '1')






f_vwap(src, is_time) =>
    var float sumSrcVol     = na
    var float sumVol        = na
    var float sumSrcSrcVol  = na

    isNewPeriod     = is_time and not is_time[1]
    sumSrcVol       := isNewPeriod ? src * volume : src * volume + sumSrcVol[1]
    sumVol          := isNewPeriod ? volume : volume + sumVol[1]
    sumSrcSrcVol    := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sumSrcSrcVol[1]
    _vwap           = not is_time ? na : sumSrcVol / sumVol

    _vwap    



f_draw_lines(is_sess, sess_css, sess_thick) =>
    var float sess_high     = na
    var float sess_low      = na

    var line line_high      = na
    var line line_low       = na

    if not is_sess
        false
    else
        if not is_sess[1]
            sess_high   := high
            sess_low    := low

            line_high := line.new(time, sess_high, time+1, sess_high, xloc = xloc.bar_time,
             extend = extend.none, color = sess_css, width = sess_thick)
            line_low := line.new(time, sess_low, time+1, sess_low, xloc = xloc.bar_time,
             extend = extend.none, color = sess_css, width = sess_thick)
            false
        else
            sess_high   := math.max(sess_high[1], high)
            sess_low    := math.min(sess_low[1], low)

            line.set_x2(line_high, time)
            line.set_x2(line_low, time)
            line.set_y1(line_high, sess_high)
            line.set_y2(line_high, sess_high)
            line.set_y1(line_low, sess_low)
            line.set_y2(line_low, sess_low)
            false



// calc rth vwap
is_rth      = time(timeframe.period, rth_vwap_sess, 'America/New_York')
rth_vwap    = use_rth_vwap ? f_vwap(close, is_rth) : na
plot(rth_vwap, title = 'RTH VWAP', style = plot.style_linebr, color = color.rgb(89, 96, 101, 39))


// calc fs vwap
is_fs       = time(timeframe.period, fs_vwap_sess, 'America/New_York')
fs_vwap     = use_fs_vwap ? f_vwap(close, is_fs) : na
plot(fs_vwap, title = 'FS VWAP', style = plot.style_linebr,
 color = fs_vwap > fs_vwap[3] ? color.rgb(0, 205, 185, 55) : color.rgb(255, 0, 0, 49))



// previous day labels





// calc on lines
is_on       = time(timeframe.period, on_sess, 'America/New_York')
f_draw_lines(is_on, color.new(#48505a, 30), 1)
bgcolor(is_on ? color.new(#48505a,82) : na)


// calc rth lines
f_draw_lines(is_rth, color.new(#48505a, 30), 3)



// custom vp






// if barstate.islast
//     label.new(chart.right_visible_bar_time, 4600, text = 'testint123', xloc = xloc.bar_time)

Overview

Gary - Levels plots an RTH VWAP line for the regular trading hours session (default 0930-1600 ET) and a full-session VWAP line for the extended period (default 1600-1559 ET). Separate high and low lines are drawn for overnight (1800-0930 ET) and RTH sessions. Each setting toggles visibility of the VWAP plots and session lines while allowing custom session time inputs in New York timezone. Lines extend across the trading day with volume-weighted calculations for VWAP values.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price chart

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
RTH VWAPbooltrueuse_rth_vwap
rth_vwap_sesssession0930-1600rth_vwap_sess
FS VWAPbooltrueuse_fs_vwap
fs_vwap_sesssession1600-1559fs_vwap_sess
ON Lines/Labelsbooltrueuse_on
on_sesssession1800-0930on_sess
RTH Lines/Labelsbooltrueuse_rth
rth_sesssession0930-1600rth_sess
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

947 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 12 days ago · GPL-3.0 GitHub repository of Moving Average Channel

PivotHighLow

by Alorse
330 stars

This indicator calculates pivot high and pivot low points on the price chart based on configurable left and right bar counts. Confirmed pivot highs and lows are plotted with negative bar offsets directly on the price chart using line and cross styles. Addition

Indicator v4 Support & resistanceOscillators & momentum Repaints
Updated 2 months ago · None stated GitHub repository of PivotHighLow

Midnight VWAP

by TradersPost
228 stars

The Midnight VWAP indicator calculates and overlays two distinct Volume Weighted Average Price (VWAP) lines on the price chart based on customizable session timeframes. It tracks an overnight or pre-market session alongside regular trading hours, resetting cal

Indicator v6 Moving averagesSessions & time
Updated 3 months ago · None stated GitHub repository of Midnight VWAP

Ichimoku Cloud

by harryguiacorn
220 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud

Deduct

by TaichiS
219 stars

This indicator displays moving average deduction reference points directly on the price chart. It plots dynamic labels on historical bars corresponding to short, medium, and long lookback periods, defaulted to 20, 60, and 120 bars. Each text label displays the

Indicator v4 Moving averagesSupport & resistance
Updated 5 years ago · None stated GitHub repository of Deduct

More Moving averages 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