Calculate average and std dev of a series
Author: kbellare
Creation Date: 5/31/2013 9:29 AM
profile picture

kbellare

#1
I couldn't find mathematical functions to calculate average and standard deviation across all the values in a data series? I used the code below, but the compiler doesn't recognize average() and stdev()

CODE:
Please log in to see this code.



Also, I'm using LinerRegSlope(150) series to determine long-term trends and when the slope exceeds its average+/-standard deviation, i call it a Bullish or Bearish long-term trend.
- If there's an easier way to define long-term trend without a significant lag, pl advise .. moving average cross-over/cross-under (e.g. SMA(100), SMA(200)) don't work well because they have significant lag.

thanks
Kiran
profile picture

Eugene

#2
QUOTE:
I used the code below, but the compiler doesn't recognize average() and stdev()


See Pages of the Category Standard Indicators:

* SMA for the average
* StdDev for standard deviation

Are both standard indicators, i.e. are prepackaged. When reviewing code examples, keep in mind that a standard DataSeries like Close - if it's accepted as a parameter by SMA/StdDev - can be substituted with any other DataSeries of your choice.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).