I have written a method for skewness but I it performs much slower than I expected. If I run the below script on more than 1000 bars it is really slow and sometimes the program gives an out of memory exception (>1500).
Could you suggest any way to optimize performance?
CODE:
Please log in to see this code.
Size:
Color:
Don't use DataSeries when you only need to find 1 value. Specifically, you've done this 2 or 3 times:
CODE:
Please log in to see this code.
Every time you change the value for AvgRet on a bar, an entire new series for Num is created... but you only need one value!
Size:
Color:
No wonder you've got OOM exceptions -- this code create
tons of DataSeries on each bar:
CODE:
Please log in to see this code.
Why not adopt gbeltrame's WL4
Skewness code? Its output seems reasonable:
CODE:
Please log in to see this code.
Size:
Color:
Thanks to both of you for your help. I had focused on obtaining the correct result for a small sample of data and paid no attention to that issue.
Eugene,
Both for reasons of practicing and because the code seemed to me somewhat complicated for the simple problem of skewness and kurtosis I decided to rewrite the two methods which now work fine (I think :) ). Is it possible to include them in the next update of Community Indicators please?
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
Is it possible to include them in the next update of Community Indicators please?
When managing over 20 solutions, "in a future update" would be a more safe term but since my renditions of gbeltrame's Skewness/Kurtosis functions were already checked in earlier today, then sure, they're coming in the next update.
Size:
Color:
Added Skewness and Kurtosis to Community Indicators v.2011.09.
Size:
Color:
Thanks Eugene
Size:
Color: