Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("Standard Deviation",shorttitle="Stdev")
- length = input(1024)
- //Trading view method
- a = sma(pow(close,2),length)
- b = pow(sum(close,length),2)/pow(length,2)
- c = sqrt(a - b)
- //Tradingview method Confirm
- d=stdev(close,length)
- //Direct method
- dev = close - sma(close, length)
- variance = sum(pow(dev, 2), length) / (length -1)
- e=sqrt(variance)
- //Direction method function
- sd(src, length) =>
- deviation = src - sma(src, length)
- variance = sum(pow(deviation, 2), length) / (length)
- sd=sqrt(variance)
- //Tradingview method function
- st_dev(Series, Period) =>
- E_1 = 0.0, E_2 = 0.0
- for i=0 to Period-1
- previousSeries = nz(Series[i])
- E_1 := E_1 + previousSeries
- E_2 := E_2 + previousSeries * previousSeries
- return = sqrt(E_2 / Period - (E_1 * E_1) / (Period * Period))
- plot(c,color=color.red)
- plot(d,color=color.green)
- plot(e,color=color.aqua)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement