Login Page - Create Account

Support Board


Date/Time: Tue, 04 Mar 2025 10:21:23 +0000



Post From: Z-Score difference

[2021-11-22 13:29:40]
User718690 - Posts: 18
I guess the difference is coming from the formula/calculation you have.
See, yours is the only Z-score thats different. Thinkorswim's and tradingview's are looking the same - smoothed, not dramatized like the one in Sierra chart.

These are the studies from Thinkorswim:
declare lower;

input price = close;
input length = 20;
input ZavgLength = 20;

#Initialize values
def oneSD = stdev(price,length);
def avgClose = simpleMovingAvg(price,length);
def ofoneSD = oneSD*price[1];
def Zscorevalue = ((price-avgClose)/oneSD);
def avgZv = average(Zscorevalue,20);

#Compute and plot Z-Score
plot Zscore = ((price-avgClose)/oneSD);
Zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Zscore.setLineWeight(2);
Zscore.assignValueColor(if Zscore > 0 then color.green else color.red);

plot avgZscore = average(Zscorevalue,ZavgLength);
avgZscore.setPaintingStrategy(paintingStrategy.LINE);



And these are from TradingView:

//@version=3
study("Z Score")
Length = input(20)
StdDevs = input(2.0)
src = input(close)

basis = sma(src,Length)

zscore = (src-basis)/stdev(src, Length)


plot(zscore, color=#55FF55)

hline(StdDevs, color=white, linestyle=dotted)
hline(-1*StdDevs, color=white, linestyle=dotted)