Indicator · Pine Script v4 · On the chart

Price vs Past

by be-thomas

This indicator draws a one-row heatmap table at the bottom center of the price chart.

View on GitHub

GitHub stars65on the repository
Pine versionv4older, still runs
Lines of code37
Settings3inputs
LicenceGPL-3.0
Last update4 days ago24 Oct 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

37 lines of Pine Script v4 from examples/v4/tradingview-docs/v4-essential-tables-04.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

v4-essential-tables-04.pine
//@version=4
study("Price vs Past", "", true)

var int MAX_LOOKBACK = 300

int     i_lookBack  = input(150, minval = 1, maxval = MAX_LOOKBACK, step = 10)
color   i_c_Bull    = input(#00FF00ff, "Bull", inline = "11")
color   i_c_Bear    = input(#FF0080ff, "Bear", inline = "11")

// ————— Function returning `_color` with `_transp` transparency.
f_colorNew(_color, _transp) =>
    // color _color : base color to derive a new transparency from. Its current transparency is ignored.
    // float _transp: 0-100 transparency of `_color` to return.
    _r = color.r(_color)
    _g = color.g(_color)
    _b = color.b(_color)
    color _return = color.rgb(_r, _g, _b, _transp)

// ————— Function draws a heatmap showing the position of the current `_src` relative to its past `_lookBack` values.
f_drawHeatmap(_src, _lookBack) =>
    // float _src     : evaluated price series.
    // int   _lookBack: number of past bars evaluated.
    // Dependency: MAX_LOOKBACK

    // Force historical buffer to a sufficient size.
    max_bars_back(_src, MAX_LOOKBACK)
    // Only run table code on last bar.
    if barstate.islast
        var _heatmap = table.new(position.bottom_center, _lookBack, 1)
        for _i = 1 to i_lookBack
            float _transp = 100. * _i / _lookBack
            if _src > _src[_i]
                table.cell(_heatmap, _lookBack - _i, 0, bgcolor = f_colorNew(i_c_Bull, _transp))
            else
                table.cell(_heatmap, _lookBack - _i, 0, bgcolor = f_colorNew(i_c_Bear, _transp))

f_drawHeatmap(high, i_lookBack)

Overview

On the last bar it compares the current high with each of the previous lookback highs. A cell is bull-colored when the current high is above that past high and bear-colored otherwise. Transparency increases with the age of the compared bar. The lookback length and the two colors are the main settings. It does not generate trade signals or exits.

Details

Published by

be-thomas on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Screeners & dashboards

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.

Topics

algorithmic-tradingbacktestingcompilerfintechjavascriptpinescripttechnical-analysistradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
i_lookBackint150i_lookBack
Bullcolor#00FF00ffi_c_Bull
Bearcolor#FF0080ffi_c_Bear
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

Symbol Info Helper

by everget
948 stars

Symbol Info Helper is an informational utility script that displays metadata about the currently selected instrument directly on the main price chart. It gathers built-in symbol properties including ticker identifier, description, instrument type, point value,

Indicator v4 Screeners & dashboards
Updated 10 days ago · GPL-3.0 GitHub repository of Symbol Info Helper
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table

3938 Tracker

by Allen1212
303 stars

3938 Tracker visualizes historical buying and selling activity from ARK Invest funds directly on the main price chart. It plots labels at specific timestamps corresponding to trade dates, indicating buy or sell actions along with the count of participating ETF

Indicator v4 Screeners & dashboards
Updated 2 years ago · None stated GitHub repository of 3938 Tracker

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