Advertisement
danucante

Untitled

Nov 11th, 2023
362
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. //@version=5
  2. // original code by // @author LazyBear
  3. // I have converted his code to latest PineScript version 4 | I am not the creator of this indicator!
  4. // I am not the creator of this indicator!, I have only added few lines form line: 20 to line: 25
  5. // and updated few syntax to latest pine version (eg:- blue to color.blue and similar things like that)
  6. indicator(title='Coral Trend Indicator [LazyBear] || v4 pine by Unknown_TracerBunny', shorttitle='CTI', overlay=true)
  7. src = input.source(title='Source', defval=close, group='CTI')
  8. sm = input.int(21, title='Smoothing Period', group='CTI')
  9. cd = input.float(0.4, title='Constant D', group='CTI')
  10.  
  11. bar_col = input.bool(false, title='Color Bars', inline='br', group='Color mode')
  12. flat = input.color(title='Line', defval=color.new(color.blue, 0), inline='br', group='Color mode')
  13.  
  14. raise = input.color(title='Color', defval=color.new(color.green, 0), inline='col', group='Style')
  15. fall = input.color(title='Color', defval=color.new(color.red, 0), inline='col', group='Style')
  16. di = (sm - 1.0) / 2.0 + 1.0
  17. c1 = 2 / (di + 1.0)
  18. c2 = 1 - c1
  19. c3 = 3.0 * (cd * cd + cd * cd * cd)
  20. c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
  21. c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
  22. var float i1 = na
  23. var float i2 = na
  24. var float i3 = na
  25. var float i4 = na
  26. var float i5 = na
  27. var float i6 = na
  28. i1 := c1 * src + 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. Cto = -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 = Cto - nz(Cto[1]) > syminfo.mintick ? green : Cto - nz(Cto[1]) < syminfo.mintick ? red : blue
  40. bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
  41. tc = bar_col ? flat : bfrC
  42. plot(Cto, title='Trend', linewidth=3, style=plot.style_stepline, color=tc, editable=false)
  43. barcolor(bar_col ? bfrC : na, editable=false)
  44.  
  45. shift_up = bfrC[1] == fall and bfrC == raise
  46. shift_dn = bfrC[1] == raise and bfrC == fall
  47. plotshape(shift_up, title='Buy', text='Buy', textcolor=raise, style=shape.triangleup, location=location.belowbar, color=color.new(#2dac32, 0))
  48. plotshape(shift_dn, title='Sell', text='Sell', textcolor=fall, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0))
  49.  
  50. alertcondition(shift_up, title='Alert for Buy', message='Buy')
  51. alertcondition(shift_dn, title='Alert for Sell', message='Sell')
  52.  
  53.  
Advertisement
Comments
  • # 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