18 lines
569 B
Plaintext
18 lines
569 B
Plaintext
//@version = 5
|
|
indicator("NYSE Cumulative New Highs New Lows", overlay = false)
|
|
|
|
var cumulativeNewHighsLows = float(na)
|
|
|
|
newHighs = request.security("HIGN", "D", close)
|
|
newLows = request.security("LOWN", "D", close)
|
|
|
|
newHighsLows = nz(cumulativeNewHighsLows) + (newHighs - newLows)
|
|
cumulativeNewHighsLows := newHighsLows
|
|
|
|
mean = ta.sma(cumulativeNewHighsLows, 252)
|
|
stdev = ta.stdev(cumulativeNewHighsLows, 252)
|
|
zScore = (cumulativeNewHighsLows - mean) / stdev
|
|
plot(zScore)
|
|
|
|
regimeColor = zScore > 0 ? color.green : color.red
|
|
bgcolor(color.new(regimeColor, transp = 75)) |