Indicator · Pine Script v4 · On the chart

Ari zScore

by alessioricco

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.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code95
Settings8inputs
LicenceApache-2.0
Last update2 years ago28 Jan 2024

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

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.

Details

Published by

alessioricco on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Volatility & bands, Mean reversion

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
Fastint5periodFast
Slowint20periodSlow
St Devint20periodStDev
z first bandint1zscoreMin
Show BandsboolfalseshowMAGraph
Show zScore lineboolfalseshowZScore
Show zScore crossbooltrueshowZScoreCross
Show PSARboolfalseshowPSAR
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

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

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]

Antigravity Elite

by eltonaguiar
4 stars

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

Indicator v6 Oscillators & momentumMoving averages
Updated today · None stated GitHub repository of Antigravity Elite

BB_signal1

by subhrapratim07
1 stars

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

Indicator v5 Volatility & bandsOscillators & momentum
Updated 2 years ago · None stated GitHub repository of BB_signal1

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

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup
285 stars

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

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

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