Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- // original code by // @author LazyBear
- // I have converted his code to latest PineScript version 4 | I am not the creator of this indicator!
- // I am not the creator of this indicator!, I have only added few lines form line: 20 to line: 25
- // and updated few syntax to latest pine version (eg:- blue to color.blue and similar things like that)
- indicator(title='Coral Trend Indicator [LazyBear] || v4 pine by Unknown_TracerBunny', shorttitle='CTI', overlay=true)
- src = input.source(title='Source', defval=close, group='CTI')
- sm = input.int(21, title='Smoothing Period', group='CTI')
- cd = input.float(0.4, title='Constant D', group='CTI')
- bar_col = input.bool(false, title='Color Bars', inline='br', group='Color mode')
- flat = input.color(title='Line', defval=color.new(color.blue, 0), inline='br', group='Color mode')
- raise = input.color(title='Color', defval=color.new(color.green, 0), inline='col', group='Style')
- fall = input.color(title='Color', defval=color.new(color.red, 0), inline='col', group='Style')
- di = (sm - 1.0) / 2.0 + 1.0
- c1 = 2 / (di + 1.0)
- c2 = 1 - c1
- c3 = 3.0 * (cd * cd + cd * cd * cd)
- c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
- c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
- var float i1 = na
- var float i2 = na
- var float i3 = na
- var float i4 = na
- var float i5 = na
- var float i6 = na
- i1 := c1 * src + c2 * nz(i1[1])
- i2 := c1 * i1 + c2 * nz(i2[1])
- i3 := c1 * i2 + c2 * nz(i3[1])
- i4 := c1 * i3 + c2 * nz(i4[1])
- i5 := c1 * i4 + c2 * nz(i5[1])
- i6 := c1 * i5 + c2 * nz(i6[1])
- Cto = -cd * cd * cd * i6 + c3 * i5 + c4 * i4 + c5 * i3
- // --------------------------------------------------------------------------
- // For the Pinescript coders: Determining trend based on the mintick step.
- // --------------------------------------------------------------------------
- //bfrC = Cto - nz(Cto[1]) > syminfo.mintick ? green : Cto - nz(Cto[1]) < syminfo.mintick ? red : blue
- bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
- tc = bar_col ? flat : bfrC
- plot(Cto, title='Trend', linewidth=3, style=plot.style_stepline, color=tc, editable=false)
- barcolor(bar_col ? bfrC : na, editable=false)
- shift_up = bfrC[1] == fall and bfrC == raise
- shift_dn = bfrC[1] == raise and bfrC == fall
- plotshape(shift_up, title='Buy', text='Buy', textcolor=raise, style=shape.triangleup, location=location.belowbar, color=color.new(#2dac32, 0))
- plotshape(shift_dn, title='Sell', text='Sell', textcolor=fall, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0))
- alertcondition(shift_up, title='Alert for Buy', message='Buy')
- alertcondition(shift_dn, title='Alert for Sell', message='Sell')
Advertisement
Comments
-
- 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