Indicator · Pine Script v5 · Own pane

RedK Trader Pressure Index (TPX)

by regalouisei· code credited to RedKTrader

Calculates buying and selling pressure by evaluating high and low movements relative to a two-bar price range.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code79
Settings7inputs
LicenceNone statedfile: MPL-2.0
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

79 lines of Pine Script v5 from pinescript/editors_picks/redk-trader-pressure-index-tpx-v10.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

redk-trader-pressure-index-tpx-v10.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader

//@version=5
indicator('RedK Trader Pressure Index (TPX)', shorttitle='RedK_TPX v5.0', overlay=false, timeframe='', precision=1)

// ======================================================================================================================
// Inputs
// ======================================================================================================================
length  = input.int(title='Avg Length',         defval=7, minval=1)
smooth  = input.int(title='Smoothing',          defval=3, minval=1)

// ****    CLevel is the "critical or control" level, whoever builds pressure that exceeds that level will be in control
clevel  = input.int(title='Control Level',      defval=30, minval=5, maxval=100)

// version 3.0 - adding optional pre-smoothing - will cause a signal lag of ~1 bar @ value of 3 - will be off by default   
pre_s   = input.bool(title='Pre-smoothing?',    defval=false,       inline='pre-smoothing')
pre_sv  = input.int(title='',                   defval=3, minval=1, inline='pre-smoothing')

// ======================================================================================================================
// Calculations
// ======================================================================================================================
//R is the 2-bar range used as "baseline" or denominator 
R           = ta.highest(2) - ta.lowest(2)

// Bull pressure is represented by how far they can pull the high and the low of previous bar up relative to the 2-bar range
hiup        = math.max(ta.change(high), 0)
loup        = math.max(ta.change(low), 0)
bulls       = math.min((hiup + loup) / R, 1) * 100  //prevent big gaps causing a % over 100%
avgbull     = ta.wma(nz(bulls), length)

avgbulls    = pre_s ? ta.wma(avgbull, pre_sv) : avgbull

// Bear pressure is represented by how far they can push the high and the low of previous bar down relative to the 2-bar range
hidn        = math.min(ta.change(high), 0)
lodn        = math.min(ta.change(low), 0)
bears       = math.max((hidn + lodn) / R, -1) * -100  //convert to positive value
avgbear     = ta.wma(nz(bears), length)

avgbears    = pre_s ? ta.wma(avgbear, pre_sv) : avgbear

net         = avgbulls - avgbears
TPX         = ta.wma(net, smooth)  // final smoothing

// ======================================================================================================================
// colors & plots
// ======================================================================================================================
col_bulls   = #33ff0099  // 40% transp
col_bears   = #ff111166  // 60% transp
col_level   = #ffee0070
col_TPXup   = color.white
col_TPXdn   = color.gray
TPXBullish  = TPX > 0

hline(0, color=col_level, linestyle=hline.style_solid, linewidth=1, editable=false)
hline(clevel, title='Control Level', color=col_level, linestyle=hline.style_dotted, linewidth=2)

plot(avgbulls,  title='Bull Pressure',  color=col_bulls, style=plot.style_area,     linewidth=3)
plot(avgbears,  title='Bear Pressure',  color=col_bears, style=plot.style_area,     linewidth=3)
plot(TPX,       title='Net Pressure',   color=TPXBullish ? col_TPXup : col_TPXdn,   linewidth=3)

// ======================================================================================================================
// version 4.0 adds Dominant Pressure Signal and enables basic Alerts

slevel_on   = input.bool(title='Pressure Signal Line?', defval=false,                               inline='signal')
slevel      = input.int(title='',                       defval=70, minval=0, maxval=100, step=5,    inline='signal')

maxbulls    = avgbulls >= clevel
maxbears    = avgbears >= clevel
TPXswing    = ta.cross(TPX, 0)

plot(maxbears and slevel_on ? slevel : na, 'Cold',  style=plot.style_circles,   color=color.new(color.maroon, 0),   linewidth=3)
plot(maxbulls and slevel_on ? slevel : na, 'Hot',   style=plot.style_cross,     color=color.new(color.green, 0),    linewidth=3)

alertcondition(maxbulls, 'TPX Bulls in Control',    'TPX Bull Pressure >= Control Level')
alertcondition(maxbears, 'TPX Bears in Control',    'TPX Bear Pressure >= Control Level')

//  v5.0 adds alert of TPX line changing color (swinging around the 0 line)
alertcondition(TPXswing, 'Net Pressure Swing',      'Net Pressure Swing Detected!')

Overview

Bull and bear pressures are averaged using weighted moving averages with optional pre-smoothing, and net pressure is derived through an additional smoothing phase. The indicator draws bull and bear pressure areas, a colored net pressure line, a zero baseline, and an adjustable control level in a separate pane.

Details

Published by

regalouisei on GitHub

Code credit

RedKTrader, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

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
Avg Lengthint7length
Smoothingint3smooth
Control Levelint30clevel
Pre-smoothing?boolfalsepre_s
pre_svint3pre_sv
Pressure Signal Line?boolfalseslevel_on
slevelint70slevel
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

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

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