Hello,
can anyone help me write an indicator based on this:
https://www.tradingview.com/script/25KCgL9H/Simple moving average deviation rate and standard deviation.
The bollinger band is momentum value standard devition.
Bat the bollinger band is not normal distribution to close price.
Moving average deviation rate is normal distribution.
This indicator is draw Moving average deviation rate and fill area 2σ standard devition.
If it exceeds 2σ, it is a trading opportunity.
//@version=3
study("Moving average deviation rate", overlay=false)
//input
_maPeriod = input(21, title="Moving average period")
//deviation rate
_sma = sma(close, _maPeriod)
_rate = close / _sma * 100 - 100
//deviation rate std
_stdCenter = sma(_rate, _maPeriod * 2)
_std = stdev(_rate, _maPeriod * 2)
_plusDev = _stdCenter + _std * 2
_minusDev = _stdCenter - _std * 2
plot(_rate, color=red)
_plotCenter = plot(_stdCenter, color=green)
_plotPlus = plot(_plusDev, color=green)
_plotMinus = plot(_minusDev, color=green)
fill(_plotCenter, _plotPlus, color=green)
fill(_plotCenter, _plotMinus, color=green)
thank you in advance for your help !!