xmd79

TSI MACD by Jwammo12

Jan 1st, 2023
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. //@version=5
  2. indicator(title='TSI MACD by Jwammo12', shorttitle='TSI_MACD_JW')
  3.  
  4. // Getting inputs
  5. fast_length = input(title='Fast Length', defval=8)
  6. slow_length = input(title='Slow Length', defval=21)
  7. First_R = input(title='First R', defval=8)
  8. Second_S = input(title='Second S', defval=5)
  9. src = input(title='Source', defval=close)
  10. signal_length = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9)
  11. sma_signal = input(title='Simple MA(Signal Line)', defval=false)
  12.  
  13.  
  14. // Plot colors
  15. col_grow_above = #26A69A
  16. col_grow_below = #FFCDD2
  17. col_fall_above = #B2DFDB
  18. col_fall_below = #EF5350
  19. col_macd = #0094ff
  20. col_signal = #ff6a00
  21.  
  22. // Calculating
  23. fast_ma = ta.ema(src, fast_length)
  24. slow_ma = ta.ema(src, slow_length)
  25. macd = fast_ma - slow_ma
  26.  
  27.  
  28. MTM = macd - macd[1]
  29. ABSMTM = math.abs(MTM)
  30.  
  31. EMA_MTM = ta.ema(MTM, First_R)
  32. EMA_ABSMTM = ta.ema(ABSMTM, First_R)
  33.  
  34. EMA2_MTM = ta.ema(EMA_MTM, Second_S)
  35. EMA2_ABSMTM = ta.ema(EMA_ABSMTM, Second_S)
  36.  
  37. TSI = 100.0 * EMA2_MTM / EMA2_ABSMTM
  38.  
  39. signal = sma_signal ? ta.sma(TSI, signal_length) : ta.ema(TSI, signal_length)
  40.  
  41. hline(0)
  42. plot(TSI, title='TSI_MACD', color=color.new(col_macd, 0))
  43. plot(signal, title='Signal', color=color.new(col_signal, 0))
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment