Posted Friday January 06 2012
I created an indicator which returns all min and max values of a data series (daily data).
If e.g. I have found the first minimum then I fix (store) the number (minidx)of this bar and go on with searching for the next maximum. If I have found the next maximum its number (maxidx) is also fixed (stored) and I start to search again for the next minimum and so on.
Let's assume the indicator produces the following result series:
0,0,0,0,0,0,0,minimum,tmpmax,tmpmax,tmpmax,maximum,tmpmin,tmpmin,tmpmin,tmpmin,tmpmin,minimum,tmpmax,tmpmax,tmpmax,tmpmax,tmpmax,maximum,tmpmin, and so on!
At the moment I fixed a minimum or a maximum I want to change some resluts inbetween.
E.g. If I fixed a new maximum then I want to change the values between the previously found minimum at minidx+1 and the current found maximum at maxidx -1 with the currently found maximum value.
The new result series shall look like this:
0,0,0,0,0,0,0,minimum,maximum,maximum,maximum,maximum,minimum,minimum,minimum,minimum,minimum,minimum,maximum,maximum,maximum,maximum,maximum,maximum,tmpmin, and so on!
In the documentation I read somthing about OldValuesChange and OldestValueChanged property but I'm not sure how to use these properties within my indicator.
Thanks in advance,
I'd recommend deriving your indicator class from SeriesCalculatorBase. Then you can create your own list to store the indicator data, and you can change the older data as you want.
The OldValuesChange and OldestValueChanged properties were put there to allow other indicators to be recalculated when your indicator changes its old values. However, it would make it too complicated to write indicators that supported this, so this isn't supported. So if you take an SMA of your indicator or something, the SMA won't be recalculated with the old values that you change.
Hi Daniel. Could you please expand on this idea of how to change past values?
As an example of what I mean, I'd like to create an indicator that is similar to ZigZag where the last leg is considered changeable until the start of a new leg is confirmed. i.e. I may need to go back and change some "tenative" indicator values. I would also like these changing values reflected on the chart.
Would I do this with the "SeriesCalculatorBaseWithValues" class? i.e. change the values in the _values variable when needed, with a corresponding change to the OldestValueChanged index? The getter for OldValuesChange would also need to be true.
I've tried to look at some of the sample code for inspiration here, but it is confusing. For example, the ZigZag indicator code seems to indicate that it derives from IndicatorBase, but it uses _values and as far as I can tell _values is only defined for SeriesCalculatorBaseWithValues.
You mentioned that some of the "Old..." fields are not supported due to complications like indicator chaining, but I'm not planning to do chaining here. I'm just trying to fashion an indicator similar to ZigZag that is capable of dynamic values for recent bars.
Any help you can provide will be much appreciated!!!
Thursday August 20 2015 by