Advertisement
Guest User

Standard Deviation Script

a guest
Oct 31st, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // Standard Deviation from Open Price //
  2. study(title="StdDev", shorttitle="StdDev", overlay = true )
  3.  
  4. Length = input(defval = 288, title="Lookback Period........................................................ *Note: Standard Deviation tends to increase commensurate to lookback period*")
  5. Basis = input(type=source, defval=open, title="Source")
  6.  
  7. sd1 = input(1 , title="X Standard Deviation (Default 1)")
  8. sd2 = input(2 , title="X Standard Deviation (Default 2)")
  9. sd3 = input(3 , title="X Standard Deviation (Default 3)")
  10.  
  11. // Standard Deviation will fall on a bell curve with .5 of it on the right of the mean and .5 of it on the left of mean
  12. // That's what these do
  13. ssd1 = sd1 / 2
  14. ssd2 = sd2 / 2
  15. ssd3 = sd3 / 2
  16.  
  17. sd = stdev(Basis, Length)
  18.  
  19. z1 = Basis + (ssd3 * sd)
  20. z2 = Basis + (ssd2 * sd)
  21. z3 = Basis + (ssd1 * sd)
  22. z4 = Basis - (ssd1 * sd)
  23. z5 = Basis - (ssd2 * sd)
  24. z6 = Basis - (ssd3 * sd)
  25.  
  26. // SD plot//
  27. plot(z1, linewidth=2, style=circles, color=green, offset=0, title="+3 sd")
  28. plot(z2, linewidth=2, style=circles, color=blue, offset=0, title="+2 sd")
  29. plot(z3, linewidth=2, style=circles, color=red, offset=0, join=true, title="+1 sd")
  30. plot(z4, linewidth=2, style=circles, color=red, offset=0, join=true, title="-1 sd")
  31. plot(z5, linewidth=2, style=circles, color=blue, offset=0, title="-2 sd")
  32. plot(z6, linewidth=2, style=circles, color=green, offset=0, title="-3 sd")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement