I'm trying to code John Ehlers Truncated Indicator that he published in Traders Tips July 2020. The code I have does not indicate any errors in the thinkScriptEditor, but does not produce a plot.
I would appreciate some assistance as to where I have gone wrong with coding and any guidance of where to go to get the indicator working.
declare lower;
input Period = 20;
input Bandwidth = .1;
input Length = 10; #must be less than 98 due to array size
def L1 = Cos(360 / 180 * Double.Pi / Period);
def G1 = Cos(360 / 180 * Double.Pi * Bandwidth / Period);
def S1 = 1 / G1 - Sqrt( 1 / (G1 * G1) - 1);
def BP = CompoundValue(3, .5 * (1 - S1) * (close - close[2]) + L1 * (1 + S1) * BP[1] - S1 * BP[2],0);
def Trunc = fold i = -length to 1 do .5 * (1 - S1)(GetValue(Close,i - 1) - GetValue(Close,i + 1)) + L1(1 +
S1)*GetValue(Trunc,(i + 1)) - S1*GetValue(Trunc,i + 2);
plot BPT = Trunc[1];
Thanks!
I would appreciate some assistance as to where I have gone wrong with coding and any guidance of where to go to get the indicator working.
declare lower;
input Period = 20;
input Bandwidth = .1;
input Length = 10; #must be less than 98 due to array size
def L1 = Cos(360 / 180 * Double.Pi / Period);
def G1 = Cos(360 / 180 * Double.Pi * Bandwidth / Period);
def S1 = 1 / G1 - Sqrt( 1 / (G1 * G1) - 1);
def BP = CompoundValue(3, .5 * (1 - S1) * (close - close[2]) + L1 * (1 + S1) * BP[1] - S1 * BP[2],0);
def Trunc = fold i = -length to 1 do .5 * (1 - S1)(GetValue(Close,i - 1) - GetValue(Close,i + 1)) + L1(1 +
S1)*GetValue(Trunc,(i + 1)) - S1*GetValue(Trunc,i + 2);
plot BPT = Trunc[1];
Thanks!