check below link for release note with instruction
https://www.tradingview.com/script/v8sBugsW-RedK-Trader-Pressure-Index-TPX-v1-0/
CSS:
#// 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'
#https://www.tradingview.com/script/v8sBugsW-RedK-Trader-Pressure-Index-TPX-v1-0/
# Converted by Sam4Cok@Samer800 - 08/2022
# Request from https://usethinkscript.com/ memeber
#// Inputs
#//============================================
input length = 7; # 'Avg Length'
input smooth = 3; # 'Smoothing'
#// CLevel is the "critical or control" level, whoever builds pressure that exceeds that level will be in control
input ControlLevel = 30; # 'Control Level'
#// version 3.0 - adding optional pre-smoothing - will cause a signal lag of ~1 bar @ value of 3 - will be off by default
input UsePerSmooth = no; # 'Pre-smoothing?'
input PreSmoothing = 3; # 'pre-smoothing'
#// version 4.0 adds Dominant Pressure Signal and enables basic Alerts
input SignalLine = yes; # 'Pressure Signal Line?'
input sigLevel = 70; # 'signal'
#==============================================
declare lower;
def na = Double.NaN;
script nz {
input data = 0;
input replacement = 0;
def ret_val = if IsNaN(data) then replacement else data;
plot return = ret_val;
}
#// =========================================================================
#// Calculations
#// =========================================================================
#//R is the 2-bar range used as "baseline" or denominator
def R = Highest(high, 2) - Lowest(low, 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
def hiup = Max((high - high[1]), 0);
def loup = Max((low - low[1]), 0);
def bulls = Min((hiup + loup) / R, 1) * 100; # //prevent big gaps causing a % over 100%
def avgbull = WMA(bulls, length);
def avgbulls = if UsePerSmooth then WMA(avgbull, PreSmoothing) else 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
def hidn = Min((high - high[1]), 0);
def lodn = Min((low - low[1]), 0);
def bears = Max((hidn + lodn) / R, -1) * -100; #//convert to positive value
def avgbear = WMA(bears, length);
def avgbears = if UsePerSmooth then WMA(avgbear, PreSmoothing) else avgbear;
def net = avgbulls - avgbears;
def TPX = WMA(net, smooth); # // final smoothing
#// ===============================================================
#// Colors & plots
#// ===============================================================
DefineGlobalColor("col_bulls" , CreateColor(51,255,0));
DefineGlobalColor("col_bears" , CreateColor(255,17,17));
DefineGlobalColor("col_level" , Color.GRAY);
DefineGlobalColor("col_TPXup" , Color.WHITE);
DefineGlobalColor("col_TPXdn" , Color.GRAY);
##########################################################
plot TPXLine = TPX; # 'Net Pressure'
TPXLine.AssignValueColor( if TPX > 0 then GlobalColor("col_TPXup") else GlobalColor("col_TPXdn"));
TPXLine.SetLineWeight(3);
plot zeroLine = 0;
zeroLine.SetDefaultColor(GlobalColor("col_level"));
plot CLine = ControlLevel; # 'Control Level'
CLine.SetDefaultColor(GlobalColor("col_level"));
CLine.SetPaintingStrategy(PaintingStrategy.DASHES);
plot Bearavg = avgbears; # 'Bear Pressure'
Bearavg.SetDefaultColor(GlobalColor("col_bears"));
Bearavg.SetLineWeight(2);
plot Bullavg = avgbulls; # 'Bull Pressure'
Bullavg.SetDefaultColor(GlobalColor("col_bulls"));
Bullavg.SetLineWeight(2);
#// version 4.0 adds Dominant Pressure Signal and enables basic Alerts
def maxbulls = avgbulls >= ControlLevel;
def maxbears = avgbears >= ControlLevel;
def TPXswing = crosses(TPX, 0);
plot cold = if maxbears and SignalLine then sigLevel else na; # 'Cold area'
cold.SetPaintingStrategy(PaintingStrategy.POINTS);
cold.SetDefaultColor(Color.RED);
cold.SetLineWeight(2);
plot hot = if maxbulls and SignalLine then sigLevel else na; # 'Hot area'
hot.SetPaintingStrategy(PaintingStrategy.SQUARES);
hot.SetDefaultColor(Color.LIME);
hot.SetLineWeight(2);
addCloud(Bullavg,0,GlobalColor("col_bulls"));
addCloud(Bearavg,0,GlobalColor("col_bears"));
#### END Code