Indicator · Pine Script v5 · Own pane

RedK Trader Pressure Index (TPX)

by theonetrade· code credited to RedKTrader

The RedK Trader Pressure Index (TPX) measures buying and selling pressure by assessing directional movement of candle highs and lows relative to a two-bar range.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code79
Settings7inputs
LicenceMIT
Last update2 weeks ago8 Nov 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 assets/indicator/bit-exact/redk_trader_pressure_index_tpx_v1_0_v8sBugsW.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

redk_trader_pressure_index_tpx_v1_0_v8sBugsW.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

RedK Trader Pressure Index (TPX) computes bull and bear pressure components using weighted moving averages, then derives a smoothed net pressure index. The indicator plots bull and bear pressure areas along with the net pressure line in a separate pane. Customizable settings include averaging length, smoothing periods, control threshold levels, and an optional pre-smoothing filter.

Details

Published by

theonetrade on GitHub

Code credit

RedKTrader, as written in the script's header

Draws

Separate pane below the 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.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

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

947 stars

The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th

Indicator v4 Oscillators & momentumMoving averages
Updated 5 weeks ago · GPL-3.0 GitHub repository of Derivative Oscillator

Beep Boop

by magic8bot
408 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

MACD

by Alorse
368 stars

This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing

Indicator v4 Oscillators & momentumMoving averages
Updated 3 months ago · None stated GitHub repository of MACD

[TVT] OBV with EMA

by namuan
321 stars

Calculates On-Balance Volume (OBV) alongside two Exponential Moving Averages (EMAs) applied directly to the cumulative OBV line. The indicator tracks volume flow relative to price movement and smooths it using short-term and longer-term EMAs to highlight volum

Indicator v6 VolumeOscillators & momentum
Updated 8 days ago · MIT GitHub repository of [TVT] OBV with EMA
228 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 4 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

MACD-V

by harryguiacorn
220 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V

More Oscillators & momentum 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