Ari zScore calculates a z-score as the difference between a fast and a slow simple moving average of close, divided by the standard deviation of close.
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
95 lines of Pine Script v4 from ARI-zScore.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.
ARI-zScore.pine
//@version=4
study(title="Ari zScore", shorttitle="ARI-zScore", overlay=true)
src = close
periodFast = input(5, "Fast")
periodSlow = input(20, "Slow")
periodStDev = input(20, "St Dev")
zscoreMin = input(1, "z first band")
// zscoreMax = input(1.25, "z second band")
showMAGraph = input(false, "Show Bands")
showZScore = input(false, "Show zScore line")
showZScoreCross = input(true, "Show zScore cross")
showPSAR = input(false, "Show PSAR")
maFast = sma(src, periodFast)
maSlow = sma(src, periodSlow)
std = stdev(src,periodStDev)
zscore = (maFast-maSlow)/std
// if periodFast < 2
// zscore := (src-maSlow)/std
// plot(zscore, color=color.green)
start = (0.02)
increment = (0.02)
maximum = 0.2
sar =sar(start, increment, maximum)
plot(showPSAR ? sar : na, "ParabolicSAR", style=plot.style_cross, color=#2962FF)
plotshape(-1.25<zscore and zscore<=-1, style=shape.triangleup,location=location.belowbar, text="1", color=color.lime)
plotshape(-1.5<zscore and zscore<=-(1.25), style=shape.triangleup,location=location.belowbar, text="", color=color.green)
plotshape(-1.75<zscore and zscore<=-(1.5), style=shape.triangleup,location=location.belowbar, text="", color=color.olive)
plotshape(-2<zscore and zscore<=-(1.75), style=shape.triangleup,location=location.belowbar, text="", color=color.teal)
plotshape(-3<zscore and zscore<=-2, style=shape.triangleup,location=location.belowbar, text="2", color=color.teal)
plotshape(zscore<=-3, style=shape.triangleup,location=location.belowbar, text="3", color=color.teal)
// drawing when zScore = 0
plotshape(showZScoreCross and crossover(zscore,0), style=shape.diamond, location=location.belowbar, color=color.yellow, text="0",textcolor=color.white)
plotshape(1<=zscore and zscore<1.25, style=shape.triangledown,location=location.abovebar, text="1", color=color.orange)
plotshape(1.25<=zscore and zscore<1.5, style=shape.triangledown,location=location.abovebar, text="", color=color.red)
plotshape(1.5<=zscore and zscore<1.75, style=shape.triangledown,location=location.abovebar, text="", color=color.purple)
plotshape(1.75<=zscore and zscore<2, style=shape.triangledown,location=location.abovebar, text="", color=color.maroon)
plotshape(2<=zscore and zscore<3, style=shape.triangledown,location=location.abovebar, text="2", color=color.maroon)
plotshape(zscore>=3, style=shape.triangledown,location=location.abovebar, text="3", color=color.maroon)
// plotshape(zscore<-zscoreMin, style=shape.triangleup,
// location=location.belowbar, color=color.lime)
// plotshape(zscore<-zscoreMax, style=shape.triangleup,
// location=location.belowbar, color=color.teal)
// drawing top and bottom zscores
max_signalPos = highest(zscore, 20)[1] > zscore //and zscore > zscoreMax
the_signalPos = max_signalPos != max_signalPos[1] and max_signalPos == true
plotshape(the_signalPos, style=shape.square,
location=location.belowbar, color=color.white, text="T",textcolor=color.red)
min_signalPos = lowest(zscore, 20)[1] < zscore //and zscore < -zscoreMax
the_signalNeg = min_signalPos != min_signalPos[1] and min_signalPos == true
plotshape(the_signalNeg, style=shape.square,
location=location.abovebar, color=color.white, text="B",textcolor=color.green)
// drawing the band
plotFast = plot(showMAGraph ? maFast : na, color=color.yellow)
plotSlow = plot(showMAGraph ? maSlow : na, color=color.blue)
plot(showZScore ? zscore : na, color=color.green)
color = color.black
if zscore>0
color := color.yellow
if zscore>1
color := color.orange
if zscore>2
color := color.red
if zscore>3
color := color.purple
if zscore>4
color := color.fuchsia
if zscore<0
color := color.yellow
if zscore<-1
color := color.lime
if zscore<-2
color := color.green
if zscore<-3
color := color.olive
if zscore<-4
color := color.teal
fill(plot1=plotFast, plot2=plotSlow,color=color, transp=30, title="")
Overview
Ari zScore plots numbered triangles above and below price bars when that value enters fixed magnitude bands, optional diamonds when it crosses zero, and squares when a 20-bar z-score extreme turns. Optional plots add the two averages and a parabolic SAR on the price chart. Lengths and visibility inputs change the calculation and what is drawn. It does not place trades.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Fast
int
5
periodFast
Slow
int
20
periodSlow
St Dev
int
20
periodStDev
z first band
int
1
zscoreMin
Show Bands
bool
false
showMAGraph
Show zScore line
bool
false
showZScore
Show zScore cross
bool
true
showZScoreCross
Show PSAR
bool
false
showPSAR
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 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
Antigravity Elite is an overlay indicator that screens price with seven selectable components: Mercury Fear, Connors RSI-2, volatility-spike reversal, EMA stack, Supertrend, multi-sigma bands, and an optional funding proxy. Auto-Detect chooses one method, whil
This indicator plots standard Bollinger Bands consisting of an upper band, lower band, and a simple moving average directly on the price chart. It calculates the Relative Strength Index to identify overbought conditions. A bearish signal displays as a red down
This overlay indicator estimates intraday reversal probabilities from a daily session VWAP and its standard-deviation bands. It scores upside and downside setups with RSI extremes, band touches, a 9/21 EMA relationship, and candle direction, then reduces a sco
This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver
Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a