Advertisement
Guest User

Untitled

a guest
May 24th, 2024
167
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © rosentrader
  3.  
  4. //@version=5
  5. indicator("TOTAL MTPI", overlay = true)
  6.  
  7. RequestSecurityNRP(_tf, series float _exp) =>
  8. request.security(syminfo.tickerid, _tf, barstate.isconfirmed ? _exp : _exp[1])
  9.  
  10. //Coral Trend
  11. srcCoral=RequestSecurityNRP("3D", close)
  12. sm =input.int(21, title="Smoothing Period")
  13. cd = input.float(0.4, title="Constant D")
  14.  
  15. di = (sm - 1.0) / 2.0 + 1.0
  16. c1 = 2 / (di + 1.0)
  17. c2 = 1 - c1
  18. c3 = 3.0 * (cd * cd + cd * cd * cd)
  19. c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
  20. c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
  21. var float i1 = na
  22. var float i2 = na
  23. var float i3 = na
  24. var float i4 = na
  25. var float i5 = na
  26. var float i6 = na
  27.  
  28. i1 := c1*srcCoral + c2*nz(i1[1])
  29. i2 := c1*i1 + c2*nz(i2[1])
  30. i3 := c1*i2 + c2*nz(i3[1])
  31. i4 := c1*i3 + c2*nz(i4[1])
  32. i5 := c1*i4 + c2*nz(i5[1])
  33. i6 := c1*i5 + c2*nz(i6[1])
  34.  
  35. bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
  36. // --------------------------------------------------------------------------
  37. // For the Pinescript coders: Determining trend based on the mintick step.
  38. // --------------------------------------------------------------------------
  39. //bfrC = bfr - nz(bfr[1]) > syminfo.mintick ? green : bfr - nz(bfr[1]) < syminfo.mintick ? red : blue
  40. coralTrend = bfr > nz(bfr[1]) ? 1 : -1
  41.  
  42. //RSI Momentum Trend
  43. var bool positive = false
  44. var bool negative = false
  45. string RSI_group = "RSI Settings"
  46. string mom_group = "Momentum Vales"
  47. string visual = "Visuals"
  48. int Len2 = input.int(14,"RSI 1️⃣",inline = "rsi",group = RSI_group)
  49. int pmom = input.int(60," Positive above",inline = "rsi1",group =RSI_group )
  50. int nmom = input.int(45,"Negative below",inline = "rsi1",group =RSI_group )
  51. rsiMomentumSource = RequestSecurityNRP("2D", close)
  52. rsi = ta.rsi(rsiMomentumSource, Len2)
  53. //------------------- }
  54.  
  55. // ** ---> Momentums ------------- {
  56.  
  57. p_mom = rsi[1] < pmom and rsi > pmom and rsi > nmom and ta.change(ta.ema(rsiMomentumSource,5)) > 0
  58. n_mom = rsi < nmom and ta.change(ta.ema(rsiMomentumSource,5)) < 0
  59.  
  60. var rsiMomentumTrend = p_mom ? 1 : n_mom ? -1 : 0
  61.  
  62. //AFR
  63. p = input.int(14, "Period")
  64. atr_factor = input.float(2.0, "Factor", step = 0.1)
  65.  
  66. // Calculations
  67. atr = ta.atr(p)
  68. e = atr * atr_factor
  69.  
  70. afr = close
  71. afr := nz(afr[1], afr)
  72.  
  73. atr_factoryHigh = close + e
  74. atr_factoryLow = close - e
  75.  
  76. if atr_factoryLow > afr
  77. afr := atr_factoryLow
  78. if atr_factoryHigh < afr
  79. afr := atr_factoryHigh
  80.  
  81. afrTrend = afr > afr[1] ? 1 : -1
  82. afrTrend := afr == afr[1] ? afrTrend[1] : afrTrend
  83.  
  84.  
  85. colorCh = color.white
  86.  
  87. if coralTrend == 1
  88. colorCh := color.green
  89. else
  90. colorCh := color.red
  91.  
  92. barcolor(colorCh)
Advertisement
Comments
  • earnmoney9022
    1 year
    # text 0.12 KB | 0 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement