Indicator · Pine Script v5 · On the chart

VGF Price-Volume TEMA

by ryangaraygay

This indicator colors chart bars based on a Triple Exponential Moving Average (TEMA) applied to candle body volume (candle body multiplied by volume).

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code70
Settings7inputs
LicenceMIT
Last update1 year ago10 Apr 2025

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

70 lines of Pine Script v5 from price-volume-tema.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

price-volume-tema.pine
//@version=5
indicator(title="VGF Price-Volume TEMA", shorttitle="PV-TEMA", overlay=true, timeframe="", timeframe_gaps=true)
// import TradingView/ta/5

length = input.int(21, minval=1)
upColor = input.color(color.new(color.blue, 0), "up color")
downColor = input.color(color.new(color.orange, 0), "down color")
messyColor = input.color(color.black, "messy color")
messy = input.int(1500, "messy range", tooltip = "values smaller than this is considered non-trending/messy")

bv = (close-open) * volume // body x volume
bvema1 = ta.ema(bv, length)
bvema2 = ta.ema(bvema1, length)
bvema3 = ta.ema(bvema2, length)
bvout = 3 * (bvema1 - bvema2) + bvema3

b = math.abs(bvout)
b2 = math.abs(bvout[1])
b3 = math.abs(bvout[2])

isMessy = b < messy and b2 < messy and b3 < messy

upCandle = close > open

countertrend_transparency = input.int(70, title="countertrend transparency")

// series color c = input.color(color.gray, title="pending candle")

color c = na

// Function to check if the current bar is inside the previous bar
isInsideBar(currentHigh, currentLow, previousHigh, previousLow) =>
    currentHigh <= previousHigh and currentLow >= previousLow

// Get the high and low values of the last three bars
currentHigh = high
currentLow = low
previousHigh = high[1]
previousLow = low[1]
priorHigh = high[2]
priorLow = low[2]

// Check for the single inside bar pattern
singleInsideBarPattern = isInsideBar(currentHigh, currentLow, previousHigh, previousLow)

// Check for the double inside bar pattern
doubleInsideBarPattern = singleInsideBarPattern and isInsideBar(previousHigh, previousLow, priorHigh, priorLow)

// Function to check if the current bar is outside the previous bar
isOutsideBar(currentHigh, currentLow, previousHigh, previousLow) =>
    currentHigh > previousHigh and currentLow < previousLow

// Check for the outside bar pattern
outsideBarPattern = isOutsideBar(currentHigh, currentLow, previousHigh, previousLow)

string my_session = input.session("0830-1500", title='New York Session')
timeinrange(res, sess) => not na(time(res, sess)) ? true : false
in_session = timeinrange(timeframe.period, my_session)

if (in_session and doubleInsideBarPattern)
    c := color.gray
else if (in_session and outsideBarPattern)
    c := upCandle ? color.green : color.red
else
    c := isMessy ? color.black : (bvout > 0 ? color.new(upColor, upCandle ? 0 : countertrend_transparency) : color.new(downColor, not upCandle ? 0 : countertrend_transparency))

barcolor(c)

colorchanged = c != c[1]
alertcondition(barstate.isconfirmed and colorchanged, "Price Volume alert", "A change in price-volume trend has been detected.")

Overview

VGF Price-Volume TEMA categorizes market flow into trending bullish, trending bearish, or non-trending messy conditions based on a user-defined threshold. Within a specified trading session, it also detects double inside bar and outside bar candlestick patterns, coloring the bars gray, green, or red accordingly. It plots directly on the price chart and triggers alerts when the bar coloring changes.

Details

Published by

ryangaraygay on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Volume, Candlestick patterns, Moving averages, Sessions & time

Markets

Stocks, Indices, Crypto

Timeframes

M15-H1, M1-M5

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
lengthint21length
up colorcolorcolor.new(color.blue, 0)upColor
down colorcolorcolor.new(color.orange, 0)downColor
messy colorcolorcolor.blackmessyColor
messy rangeint1500messy
countertrend transparencyint70countertrend_transparency
New York Sessionsession0830-1500my_session
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

Midnight VWAP

by TradersPost
218 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
23 stars

Point-Clip Unified Indicator plots breakout and directional labels on the price chart. It scores volume spikes against a volume average, range or opening-range breaks, optional VWAP or session-anchored VWAP, fast and slow EMA trend, and a higher-timeframe EMA

Indicator v6 BreakoutVolume Repaints
Updated 3 weeks ago · Custom licence GitHub repository of Point-Clip Unified Indicator

PA Indicators

by forecho
5 stars

This indicator plots price action tools directly on the main price chart. It shades candles according to Internal Bar Strength (IBS) and optional wick-length thresholds to differentiate trend bars from trading ranges. The script tracks session bar counts durin

Indicator v6 Candlestick patternsMoving averages
Updated 8 weeks ago · None stated GitHub repository of PA Indicators

TradeKit

by tanishq-rocks
5 stars

TradeKit is an all-in-one technical analysis indicator that consolidates multiple chart overlays into a single script on the price chart. It plots up to four customizable moving averages (SMA, EMA, SMMA, WMA, or VWMA), Bollinger Bands, VWAP, and reference leve

Indicator v6 Moving averagesCandlestick patterns
Updated 3 months ago · MPL-2.0 GitHub repository of TradeKit
4 stars

This indicator recolors price candles from recent volume and range. It marks climax bars when current volume times range exceeds the prior ten-bar peak or volume is at least twice a ten-bar average, and rising bars at one and a half times that average. Bullish

Indicator v5 VolumeCandlestick patterns
Updated 9 months ago · None stated GitHub repository of Price-Volume Analysis
3 stars

Hercules Indicator 1.7 is a multi-filter trade signal generator designed to overlay entry conditions directly on the price chart. It evaluates engulfing candle patterns alongside multiple configurable filters, including trading session windows (Sydney, Tokyo,

Indicator v5 Candlestick patternsSessions & time
Updated 5 months ago · None stated GitHub repository of Hercules Indicator 1.7

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