18 lines
570 B
Plaintext
18 lines
570 B
Plaintext
//@version = 5
|
|
indicator("NASDAQ Cumulative New Highs New Lows", overlay = true)
|
|
|
|
var cumulativeNewHighsLows = float(na)
|
|
|
|
newHighs = request.security("HIGQ", "D", close)
|
|
newLows = request.security("LOWQ", "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)) |