Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- //VonKr
- study("Pretty_Weis Wave Volume", shorttitle="Pretty_Weis Wave Volume", overlay=false, resolution="")
- method = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")
- methodvalue = input(defval=14.0, type=input.float, minval=0, title="Value")
- pricesource = input(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")
- useClose = pricesource == "Close"
- useOpenClose = pricesource == "Open / Close" or useClose
- useTrueRange = input(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")
- isOscillating = input(defval=false, type=input.bool, title="Oscillating")
- normalize = input(defval=false, type=input.bool, title="Normalize")
- vol = useTrueRange == "Always" or useTrueRange == "Auto" and na(volume) ? tr : volume
- op = useClose ? close : open
- hi = useOpenClose ? close >= op ? close : op : high
- lo = useOpenClose ? close <= op ? close : op : low
- if method == "ATR"
- methodvalue := atr(round(methodvalue))
- if method == "Part of Price"
- methodvalue := close / methodvalue
- currclose = float(na)
- prevclose = nz(currclose[1])
- prevhigh = prevclose + methodvalue
- prevlow = prevclose - methodvalue
- currclose := hi > prevhigh ? hi : lo < prevlow ? lo : prevclose
- direction = int(na)
- direction := currclose > prevclose ? 1 : currclose < prevclose ? -1 : nz(direction[1])
- directionHasChanged = change(direction) != 0
- directionIsUp = direction > 0
- directionIsDown = direction < 0
- barcount = 1
- barcount := not directionHasChanged and normalize ? barcount[1] + barcount : barcount
- vol := not directionHasChanged ? vol[1] + vol : vol
- res = barcount > 1 ? vol / barcount : vol
- plot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=directionIsUp ? color.green : color.red, transp=0, linewidth=4, title="Wave Volume")
Advertisement
Add Comment
Please, Sign In to add comment