Profile Picture

Indicator calculation Start Time

Posted By DoQ 9 Years Ago
Message
DoQ
Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)
Posted Monday February 18 2008
In some of my indicators posted, I gave the option of setting the number of days to use in the calculation, i.e. 1,2,3 days. However, suppose I chose 2 days for calculation of pivots, if I have any odd number of days loaded for the chart, my last day only has 1 day in its calculation. What I want is to have the last 2 days calculations starting from the most recent day (where it matters) and not starting from bar 0. How can this be done in RE indicator plugins?


DoQ_Indicators
"better is the enemy of good enough"
Posted Monday February 18 2008
Well you can't know how many bars are left in a series at the start of the series.  Plus, when you get a new bar, there's no way to know if it's the last one or not.  So really you need to have the pivot bars change every time you get a new bar in.  This means that you are going to have a series where the previously calculated values change when a new bar comes in.  You should override the OldValuesChange property in your indicator and return true to indicate that this is the case.

Then you need to actually change the values every time a new bar comes in.  You could recalculate the whole series on each bar and access the _values field of the base class to store your data.  This is O(n^2) however, so it's not a very good solution.

A better solution would be to implement the IIndicator interface yourself instead of relying on the IndicatorBase class.  You would create a number of "Pivot Calculators" equal to the number of periods, but they would be out of synch with each other as far as which bars were used as pivot points.  Then in the indexer (LookBack method in RightEdge 1.2), you would return the value from the calculator that had a pivot point on the last bar.

Thanks,
Daniel

DoQ
Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)Supreme Being (12,651 reputation)
Posted Tuesday February 19 2008
That really is too bad this can't be done in RE, cleanly. Other platforms do support this and it is becoming more of a necessity just to keep up with other traders' platforms. Is there any flag that allows a developer access the last bar available in the database, this might be useful and maybe a simple workaround.  On second thought, that might not work either...


DoQ_Indicators
"better is the enemy of good enough"


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems