Description
Hello, I am not yet an expert of indicators and neither ta4j, and trying to develop my first indicator: the Zig Zag indicator.
This indicator seems to me peculiar, since with new close price values coming in, it might change previous calculated indicator values. This is due to the logic this indicator works.
In a nutshell:
data = {1.0, 1.1, 1.4}
zigzag(0) = 1.0
zigzag(2) = 1.4
in this case there's a (zigzag) line from 1.0 to 1.4
data = {1.0, 1.1, 1.4, 2.0}
zigzag(0) = 1.0
zigzag(3) = 2.0
in this case, where a new value of 2.0 comes in, the (zigzag) line is drawn from 1.0 to 2.0, which implies that also previous values are different, as the line inclination is now different. So zigzag(2)
is not going to be 1.4 anymore, like stated in the previous example.
Give the above, in a test like this:
BarSeries data = new MockBarSeries(numFunction, 1.0, 1.0, 1.3, 1.5, 1.6, 1.8 , 0.9, 0.8, 0.8, 0.7, 1.0, 1.1, 1.1, 1.2);
where I provide all the test data in advance, should the indicator know all values? Or it should answer knowing the values only "incrementally"?
In other words: zigzag(4)
knows only data[] from data[0]
to data[4]
or it knows data from data[0]
to data[data.length]
?
Also do you know any already implemented indicator that works similarly so I can take inspiration?
I have other questions but will start with these and see if I get traction 😄
Thanks for your help.