Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("TOTAL MTPI", overlay = true)
- // Coral Trend calculation
- A = input.int(21, title="Smoothing Period")
- B = input.float(0.4, title="Constant D")
- coralTrend(int a, float b, series float src) =>
- sm = a
- cd = b
- 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])
- bfr = -cd * cd * cd * i6 + c3 * i5 + c4 * i4 + c5 * i3
- coralTrend = bfr > nz(bfr[1]) ? 1 : -1
- coralTrend
- Cheese = request.security(syminfo.tickerid, "3D", barstate.isconfirmed ? coralTrend(A, B, close) : coralTrend(A, B, close)[1])
- // Set bar color based on trends
- colorCh = color.white
- if Cheese == 1
- colorCh := color.green
- else
- colorCh := color.red
- barcolor(colorCh)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement