Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Dynamic Momentum Gauge",overlay=false)
- bgcolor(#000000c0)
- len = input.int(100, minval=1, title="Length")
- len1 = input.int(100, minval=1, title="Normalization Length")
- m=0.0
- src = input(close, title="Source")
- r = (src / src[1] - 1) * 100
- m := ((len-1)/len)*nz(m[1]) + r/len
- s= math.abs(m)
- a = hline(0.5,color=color.rgb(61, 61, 61),linestyle = hline.style_solid)
- b = hline(1,"Min Momentum Run",color=color.rgb(29,213,96),linestyle = hline.style_solid)
- c = hline(0,"Max Momentum Run",color=color.rgb(208, 35, 35),linestyle = hline.style_solid)
- // Min-Max normalization
- s_normalized = (s - ta.lowest(s, len1)) / (ta.highest(s, len1) - ta.lowest(s, len1))
- plot1 = plot(s_normalized, color=s_normalized > 0.5 ? color.rgb(29,213,96) :color.rgb(208, 35, 35), title="Normalized Momentum",linewidth = 2)
- fill(b,c,color.new(color.blue, 90))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement