Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © jason5480
- //@version=5
- indicator(title = 'Ladder StDev',
- shorttitle = 'LStDev',
- timeframe = '',
- timeframe_gaps = true)
- import HeWhoMustNotBeNamed/arraymethods/1
- // INPUT ============================================================================================================
- stdevSrc = input.source(defval = close, title = 'StDev Src/Len', inline = 'StDev')
- stdevLength = input.int(defval = 20, title = '', minval = 1, tooltip = 'The source and the length to be used for the StDev calculation.', inline = 'StDev')
- // LOGIC ============================================================================================================
- var positiveStDevs = array.new<float>()
- var negativeStDevs = array.new<float>()
- if(close > open)
- positiveStDevs.push(stdevSrc, stdevLength)
- else
- negativeStDevs.push(stdevSrc, stdevLength)
- float ladderPositiveStDev = array.stdev(positiveStDevs, stdevLength)
- float ladderNegativeStDev = array.stdev(negativeStDevs, stdevLength)
- // PLOT =============================================================================================================
- var positiveColor = color.new(#26A69A, 0)
- plot(series = ladderPositiveStDev, title = 'Positive StDev', color = positiveColor, linewidth = 1, style = plot.style_line, trackprice = true)
- var negativeColor = color.new(#EF5350, 0)
- 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