Re: computing moving average

Home 21090308 Forums Re: computing moving average



Problem 1:
Thanks for your reply. Unfortunately I don’t really understand the mechanism behind the filter. I was at the MovingAverageCache.java and I the opened the filtering source. I was led to MovingAverage.java file. There are no formulas being written there and I could only see codes such as:

Thus, I am still not sure how the averages are being computed.

Problem 2:
Nonetheless, I attempted to solve the problem I was working on. Actually I am trying to implement a Donchian Lower Band. This signal is basically the minimum value of the stock price over a specified period. The strategy remains similar to Moving Average Crossover, namely if the Donchian Lower Band of 50 days is higher than Donchian Lower Band of 250 days, Buy. And vice versa.

Hence I can leverage on the codes that are written and the structure of the caches, I made some modifications to the MovingAverageCache file. I wrote the following. Basically removing any commands pertaining to computing averages and inserted a command to find the minimum value as written at the last part of the code (pls refer to call min()).

The file compiles but it does not evaluate beyond the first 50 days. If I changed the duration, for example 20days, the program will stop at end of that duration too.