Posted By: zcom001
Ehler's Instantaneous Trendline - 11/08/13 09:52
Hi guys,
I am just starting with Zorro and I am sorry for such a silly question.
I have been trying to code Instantaneous Trendline indicator from Ehler's Cybernetic Analysis book and I am unfortunately still getting screwed output... :-/ Could you please have a look on my code and advise me what I am doing wrong?
Instantaneous Trendline formula in EasyLanguage from Ehler's book:
My Zorro script:
The problem obviously is that value of ITrend[1] and ITrend[2] remains constant from the beginning of the test period. I really don't understand why, because I think that every new run of run function after the new bar should shift the values of ITrend...
Thank you very much for your help in advance,
zcom001
I am just starting with Zorro and I am sorry for such a silly question.
I have been trying to code Instantaneous Trendline indicator from Ehler's Cybernetic Analysis book and I am unfortunately still getting screwed output... :-/ Could you please have a look on my code and advise me what I am doing wrong?
Instantaneous Trendline formula in EasyLanguage from Ehler's book:
Code:
InstTrend = (α − (α/2)2) * Price + (α2/2) * Price[1] − (α − 3α2/4) * Price[2]) + 2 * (1 − α) * InstTrend[1] − (1 − α)2 * InstTrend[2];
My Zorro script:
Code:
var Alfa = 0.05; var ITrend[4]; function run() { StartDate = 2012; EndDate = 2013; BarPeriod = 1440; var* Price = series(price()); //Fill Instantaneous Trendline at time 0, 1 and 2 with some //values in the beginning of the testing period. if (Bar < 4) { ITrend[0] = (Price[0] + 2 * Price[1] + Price[2])/4; ITrend[1] = (Price[1] + 2 * Price[2] + Price[3])/4; ITrend[2] = (Price[2] + 2 * Price[3] + Price[4])/4; } else { // Formula for Instantaneous Trendline itself after Bar 3. ITrend[0] = (Alfa - Alfa * Alfa/4)*Price[0] + 0.5 * Alfa * Alfa * Price[1] - (Alfa - 0.75 * Alfa * Alfa)*Price[2]+2*(1-Alfa)*ITrend[1]-(1-Alfa)*(1-Alfa)*ITrend[2]; } // Plot ITrend value plot("ITrend",ITrend[0],0,RED); // Plot ITrend values at time 0, 1 and 2 for troubleshooting. plot("ITrend0",ITrend[0],NEW,RED); plot("ITrend1",ITrend[1],0,BLUE); plot("ITrend2",ITrend[2],0,YELLOW); set(PLOTNOW); }
The problem obviously is that value of ITrend[1] and ITrend[2] remains constant from the beginning of the test period. I really don't understand why, because I think that every new run of run function after the new bar should shift the values of ITrend...
Thank you very much for your help in advance,
zcom001