spartan.ts
Member
Hello, attempted to convert this script from pinescript:
https://www.tradingview.com/script/DaHLcICg-Ehlers-Instantaneous-Trend-LazyBear/
But can't get past a parameter error in "it" formula: nz(it[1], ((src + 2 * src[1] + src[2]) / 4.0))
i can see that the nz script only takes 1 parameter and likely the cause, but unsure how to mitigate it in formula.
Any help would be most appreciated. thanks
input src = hl2; # src=input(hl2, title="Source")
input a = .07; #a= input(0.07, title="Alpha", step=0.01)
input fr = NO; #fr=input(false, title="Fill Trend Region")
script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}
def it = (a - ((a * a) / 4.0)) * src + 0.5 * a * a * src[1] - (a - 0.75 * a * a) * src[2] + 2 * (1 - a ) * nz(it[1], ((src + 2 * src[1] + src[2]) / 4.0)) - (1 - a ) * (1 - a ) * nz(it[2], ((src + 2 * src[1] + src[2]) / 4.0));
def lag = 2.0 * it - nz(it[2]);
plot tline = if it > lag then it else Double.NaN;
#dl=plot(fr and (not hr)?(it>lag?lag:it):na, color=gray, style=circles, linewidth=0, title="Dummy")
AddCloud( if fr and it then it else Double.NaN, lag, Color.PINK, Color.BLUE );
https://www.tradingview.com/script/DaHLcICg-Ehlers-Instantaneous-Trend-LazyBear/
But can't get past a parameter error in "it" formula: nz(it[1], ((src + 2 * src[1] + src[2]) / 4.0))
i can see that the nz script only takes 1 parameter and likely the cause, but unsure how to mitigate it in formula.
Any help would be most appreciated. thanks
input src = hl2; # src=input(hl2, title="Source")
input a = .07; #a= input(0.07, title="Alpha", step=0.01)
input fr = NO; #fr=input(false, title="Fill Trend Region")
script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}
def it = (a - ((a * a) / 4.0)) * src + 0.5 * a * a * src[1] - (a - 0.75 * a * a) * src[2] + 2 * (1 - a ) * nz(it[1], ((src + 2 * src[1] + src[2]) / 4.0)) - (1 - a ) * (1 - a ) * nz(it[2], ((src + 2 * src[1] + src[2]) / 4.0));
def lag = 2.0 * it - nz(it[2]);
plot tline = if it > lag then it else Double.NaN;
#dl=plot(fr and (not hr)?(it>lag?lag:it):na, color=gray, style=circles, linewidth=0, title="Dummy")
AddCloud( if fr and it then it else Double.NaN, lag, Color.PINK, Color.BLUE );
Last edited by a moderator: