support for efficient calculation of "sum of f over a sliding window" type indicators
Ataman
Post subject: support for efficient calculation of "sum of f over a sliding window" type indicators
Post rating: 0
Posted: Mon 24 Mar, 2014, 14:52
User rating: 0
Joined: Thu 13 Mar, 2014, 17:17 Posts: 13 Location: Hungary,
Hi, a lot of the indicators I need are of the form Sum of f(i) over [a,b], where f is some local transformation of elements around index i from the array segment [a, b] (or rather [a, 0], where 0 corresponds to current time or index). The simplest case is when we calculate the average of elements over the interval. Let's say the interval is very long, thousands of elements long.. then recalculating the sum on every new data point would be insane.. I would rather have the last one of the elements, f(b) substracted from the sum and the new one, f(a) added. Do you have support for this type of efficient computation of indicators in the JForex-API? I guess I cannot find it... but it may still exist implemented as an optimazition feature in your compiler. Does it exist? How does it work? Is it documented anywhere? Do I need to supply a separate initilazation function? Or just trust your compiler? thanks!
API Support
Post subject: Re: support for efficient calculation of "sum of f over a sliding window" type indicators
It is up to the indicator/strategy to implement the algorithm as efficient as possible. Also for indicators there are multiple settings which determine how many values and how often they should get calculated/recalculated.