本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=3
// Copyright (c) 2018-present, Alex Orekhov (everget)
// Quasi White Noise script may be freely distributed under the MIT license.
study("Quasi White Noise", shorttitle="QWN")
divisor = input(title="Divisor", type=float, minval=1, defval=40)
useMintick = input(title="Use mintick as divisor ?", type=bool, defval=false)
src = input(title="Source", type=source, defval=close)
// Connors RSI (by Larry Connors) is used as a model of the white noise
updown(src) =>
ud = 0.0
ud := src == nz(src[1])
? 0
: src > nz(src[1])
? (nz(ud[1]) <= 0
? 1
: nz(ud[1]) + 1)
: (nz(ud[1]) >= 0
? -1
: nz(ud[1]) - 1)
getCRSI(src, rsiLength, updownLength, rocLength) =>
updownrsi = rsi(updown(src), updownLength)
percentrank = percentrank(roc(src, 1), rocLength)
crsi = avg(rsi(src, rsiLength), updownrsi, percentrank)
whiteNoiseLength = 500
crsi = getCRSI(src, whiteNoiseLength, whiteNoiseLength, 20)
whiteNoise = (crsi - 50) * (useMintick ? syminfo.mintick : 1 / divisor)
plot(whiteNoise, title="Dist", color=#351c75)
plot(sma(whiteNoise, whiteNoiseLength), title="Mean", color=#ff006e)
plot(pow(stdev(whiteNoise, whiteNoiseLength), 2), title="Variance", color=#ff6a00)