Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // © TheProfessorDev
  2. //@version=4
  3.  
  4. study(title="Relative Trend Index", shorttitle="Relative Trend Index", resolution="")
  5.  
  6.  
  7. emaplot = input (true, title="Show EMA on chart")
  8. ema_st = input(13, minval=1, title="Short Term Length")
  9. ema_lt = input(50, minval=1, title="Long Term Length")
  10. src = close
  11. out_st = ema(src, ema_st)
  12. out_lt = ema(src, ema_lt)
  13. out = (out_st/out_lt)
  14. up = out > out[1] and (close>ema(high,50))
  15. down = out < out[1] and (close<ema(low,50))
  16. up_pull = out < out[1] and (close>ema(high,50))
  17. down_pull = out > out[1] and (close<ema(low,50))
  18.  
  19. mycolor = up ? color.green : down ? color.red : down_pull ? color.yellow : up_pull ? color.white : color.blue
  20. plot(out and emaplot ? out :na, title="EMA", color=mycolor, linewidth=5)
  21.  
  22. ribm=input(false, title="Ribbon Mode")
  23. bgcolor(ribm?mycolor:na, transp=30)