@mashume : Nicely done...Thank you...
I took the liberty of adding two additional lines to further complete the recreation of the indicator:
Code:
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);
The completed script is as follows:
Code:
# https://www.tradingview.com/script/qyUwc2Al-Coral-Trend-Indicator-LazyBear/
# // @author LazyBear
# ToS Conversion: mashume
# study(title="Coral Trend Indicator [LazyBear]", shorttitle="CTI_LB", overlay=true)
declare upper;
def src = close;
input sm = 21;
input cd = 0.4;
script nz {
input data = 0;
def ret_val = if isNaN(data) then 0 else data;
plot return = ret_val;
}
def di = (sm - 1.0) / 2.0 + 1.0;
def c1 = 2 / (di + 1.0);
def c2 = 1 - c1;
def c3 = 3.0 * (cd * cd + cd * cd * cd);
def c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
def c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;
def i1 = c1*src + c2*nz(i1[1]);
def i2 = c1*i1 + c2*nz(i2[1]);
def i3 = c1*i2 + c2*nz(i3[1]);
def i4 = c1*i3 + c2*nz(i4[1]);
def i5 = c1*i4 + c2*nz(i5[1]);
def i6 = c1*i5 + c2*nz(i6[1]);
def bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);
def temp = if !isNaN(bfr) then bfr else double.nan;
def bfrC = if bfr > nz(bfr[1]) then 1 else if bfr < nz(bfr[1]) then -1 else 0;
plot ribm = temp;
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);
ribm.AssignValueColor(if bfrC == 1 then color.green else if bfrC == -1 then color.red else color.blue);
Good Luck and Good Trading