Advertisement
kocurekc

Relative Momentum Index, Pinescript

Apr 16th, 2014
1,304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. study("Relative Momentum Index")
  2. // Relative Momentum Index
  3. //
  4. // Roger Altman, February 1993, "Technical Analysis of Stocks & Commodities"
  5. //
  6. // Rewrite for Tradingview "Pine Script" by Kocurekc, April 2014
  7. // https://getsatisfaction.com/tradingview/
  8. // https://www.tradingview.com/u/kocurekc/
  9. // Code is provided as public domain, no warranty
  10.  
  11.  
  12. //******************************Using***************************
  13. //Inputs - EMA averaging length
  14. //Inputs - Momentum, lookback period for increase or decrease
  15. //Option - Upper Bound Line, which sets the upper fill level
  16. //Option - Lower Bound Line, which sets the lower fill level
  17. //******************************END*****************************
  18.  
  19. Len = input(title="EMA Averaging Length", type=integer, defval=20, minval=1)
  20. Mom = input(title="Lookback for Momentum", type=integer, defval=5, minval=1)
  21. OVB = input(title="Top Boundary", type=integer, defval=80, minval=51, maxval=100)
  22. OVS = input(title="Bottom Boundary", type=integer, defval=20, minval=0, maxval=49)
  23. InA = input(title="SMA Trendline", type=bool, defval=false)
  24. smaLen = input(title="SMA Period", type=integer, defval=10, minval=1)
  25.  
  26. emaInc = ema(max(close - close[Mom], 0), Len)
  27. emaDec = ema(max(close[Mom] - close, 0), Len)
  28. RMI = emaDec == 0 ? 0 : 100 - 100 / (1 + emaInc / emaDec)
  29.  
  30. p1 = plot(RMI >= OVB ? RMI : OVB, color=green)
  31. p2 = plot(OVB, title='OverB', color=green)
  32. p3 = plot(OVS, title='OverS', color=red)
  33. p4 = plot(RMI <= OVS ? RMI : OVS, color=red)
  34. hline(50, linestyle=dashed)
  35.  
  36. plot(RMI, color=black)
  37. plot(InA?sma(RMI,smaLen):na)
  38.  
  39. fill(p1, p2, color=green, transp=50)
  40. fill(p3, p4, color=red, transp=50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement