Reputation: 1
I try to implement ZigZag Indicator in TypeScript. My ZigZagCalculation function accepts as a parameters: Bar[] bar, deviation: number And returns array with all the zig-zag points.
My bar array has a capacity of x, so every new bar that is added placed on the first index of the array, and the value in the last index of the array is removed.
My question is: can I avoid re-calculation of the ZigZag when new Bar is added,by calculate only the two new ends of the array, instead of iterate the array all over again (in O(n))?
Thank you
My implementation so far includes regular implementation of the ZigZag, and my function returns an object of:
{
highPoints: {
index: number;
price: Bar
}[];
lowPoints: {
index: number;
price: Bar
}[];
}
Upvotes: 0
Views: 148