Advertisement
xmd79

Dynamic Momentum Gauge

Feb 17th, 2024
343
2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 2 0
  1. //@version=5
  2. indicator("Dynamic Momentum Gauge",overlay=false)
  3. bgcolor(#000000c0)
  4. len = input.int(100, minval=1, title="Length")
  5. len1 = input.int(100, minval=1, title="Normalization Length")
  6.  
  7. m=0.0
  8. src = input(close, title="Source")
  9. r = (src / src[1] - 1) * 100
  10. m := ((len-1)/len)*nz(m[1]) + r/len
  11. s= math.abs(m)
  12. a = hline(0.5,color=color.rgb(61, 61, 61),linestyle = hline.style_solid)
  13. b = hline(1,"Min Momentum Run",color=color.rgb(29,213,96),linestyle = hline.style_solid)
  14. c = hline(0,"Max Momentum Run",color=color.rgb(208, 35, 35),linestyle = hline.style_solid)
  15.  
  16. // Min-Max normalization
  17. s_normalized = (s - ta.lowest(s, len1)) / (ta.highest(s, len1) - ta.lowest(s, len1))
  18. plot1 = plot(s_normalized, color=s_normalized > 0.5 ? color.rgb(29,213,96) :color.rgb(208, 35, 35), title="Normalized Momentum",linewidth = 2)
  19. fill(b,c,color.new(color.blue, 90))
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement