xmd79

Ladder StDev

Mar 20th, 2023
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © jason5480
  3.  
  4. //@version=5
  5. indicator(title = 'Ladder StDev',
  6. shorttitle = 'LStDev',
  7. timeframe = '',
  8. timeframe_gaps = true)
  9.  
  10. import HeWhoMustNotBeNamed/arraymethods/1
  11.  
  12. // INPUT ============================================================================================================
  13. stdevSrc = input.source(defval = close, title = 'StDev Src/Len', inline = 'StDev')
  14. stdevLength = input.int(defval = 20, title = '', minval = 1, tooltip = 'The source and the length to be used for the StDev calculation.', inline = 'StDev')
  15.  
  16. // LOGIC ============================================================================================================
  17. var positiveStDevs = array.new<float>()
  18. var negativeStDevs = array.new<float>()
  19.  
  20. if(close > open)
  21. positiveStDevs.push(stdevSrc, stdevLength)
  22. else
  23. negativeStDevs.push(stdevSrc, stdevLength)
  24.  
  25. float ladderPositiveStDev = array.stdev(positiveStDevs, stdevLength)
  26. float ladderNegativeStDev = array.stdev(negativeStDevs, stdevLength)
  27.  
  28. // PLOT =============================================================================================================
  29. var positiveColor = color.new(#26A69A, 0)
  30. plot(series = ladderPositiveStDev, title = 'Positive StDev', color = positiveColor, linewidth = 1, style = plot.style_line, trackprice = true)
  31. var negativeColor = color.new(#EF5350, 0)
  32. plot(series = ladderNegativeStDev, title = 'Negative StDev', color = negativeColor, linewidth = 1, style = plot.style_line, trackprice = true)
Advertisement
Add Comment
Please, Sign In to add comment