1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
30 lines of Pine Script v5 from z-score-highlighter.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
z-score-highlighter.pine
//@version=5
indicator("Z-Score Highlighter", overlay=true)
// Function to calculate the Z-score
zscore(src, length) =>
mean = ta.sma(src, length)
stdev = ta.stdev(src, length)
(src - mean) / stdev
// Input parameters
length = input(20, title="Z-Score Length")
threshold = input(2, title="Z-Score Threshold")
// Calculate the Z-score of the closing price
z = zscore(close, length)
// Highlight bars where the Z-score is above the threshold
highlightCondition = z > threshold
highlightConditionB = z < -threshold
string my_session = input.session("0830-1500", title='NYSession')
timeinrange(res, sess) => not na(time(res, sess)) ? true : false
in_session = timeinrange(timeframe.period, my_session)
// Plot a circle at the high price when the condition is met
plotshape(series=highlightCondition and in_session, location=location.abovebar, color=color.blue, style=shape.xcross, size=size.tiny, title="Z-Score High")
plotshape(series=highlightConditionB and in_session, location=location.belowbar, color=color.orange, style=shape.xcross, size=size.tiny, title="Z-Score Low")
alertcondition(barstate.isconfirmed and in_session and (highlightCondition or highlightConditionB), "Outlier take profit alert", "An outlier has been detected. Considering take profit or tightening.")
Overview
Z-Score Highlighter identifies potential statistical outliers by checking if the Z-score breaches positive or negative threshold levels during a user-configurable trading session. Outliers within session hours are marked directly on the main price chart using cross shapes above or below price bars.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Z-Score Length
int
20
length
Z-Score Threshold
int
2
threshold
NYSession
session
0830-1500
my_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.
This indicator plots an average daily range from hourly high-low ranges stored for each hour across a selectable number of days. It highlights time sessions on the price chart and can show a timeline and the current range box. Optional filters use a volatility
This indicator overlays statistical standard deviation bands around a basis (SMA or VWAP) and generates momentum-filtered breakout and pullback signals during a specified trading session. Long and short signals trigger on band crosses confirmed by Heikin Ashi
Gold Dominator Pro is a multi-indicator overlay designed primarily for gold trading. It combines higher-timeframe exponential moving averages with momentum oscillators like RSI, MACD, and StochRSI, alongside volatility tools such as ATR, Bollinger Bands, and A
Overlay indicator for XAUUSD gold that draws predicted support and resistance levels at 08:00 and 19:00 SGT on the price chart along with buy and sell take-profit levels spaced by ATR multiples. It generates RSI reversal signals as triangles when the indicator
The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha
This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre