While coding some indicators, I've found the need for a Median filter (similar to TradeStation). I thought the following code would be a nice addition to the Community.Components library..
CODE:
Please log in to see this code.
Size:
Color:
Hi Tim,
Thanks. By the way, is the int bar parameter really required?
Size:
Color:
Yes. To copy the values from the series to the temporary array, I do the following:
aTmp[i] = ds[bar - i];
TradeStation seems to know what bar you are on whereas WLP needs that passed as a parameter.
Size:
Color:
Oops sorry, I overlooked it! Nevermind.
Size:
Color:
No problem. It's helpful to have someone else reviewing my code to make sure I didn't make any stupid mistakes.
I stumbled onto the need for the Median filter while porting some of John Ehlers algorithms to WLP for my own use.
AdaptiveLaguerre Bug with its Median filter??I noticed that indicator AdaptiveLaguerre in the Community.Indicators library had implemented a median filter inline, but the code puzzled me. Now I believe there is an bug in the code. The following code segment in AdaptiveLaguerre could return zero even if zero is not in the source data...
CODE:
Please log in to see this code.
To show what I mean, I've extracted the code and put it into a strategy for a controlled test...
CODE:
Please log in to see this code.
Notice that tmp does not have zero in any of the source data; however, the final result for alpha is zero.
As long as AdaptiveLaguerre is used with a DataSeries that can not contain negative values, the issue in the code above should not affect the calculations. Using AdaptiveLaguerre with prices should be fine.
Since there was already one indicator in Community.Indicators that needed this functionality, I assumed there could probably be more in the future that might need a Median filter.
Size:
Color:
Thanks again, Median will see the light in Community.Components 2010.12.
Size:
Color:
Size:
Color:
Eugene, I didn't even notice that this has already been implemented in the standard indicators...
http://www2.wealth-lab.com/WL5WIKI/Median.ashxI'd recommend removing my addition to Community.Components based on this new find. They appear to be the same.
Size:
Color:
Well, we reinvented the wheel... Happens sometimes. Thanks for the heads-up. :) Sure, no need in adding this to Community.Components.
Size:
Color: