I have been using an afl to scan for stocks that are rising for the past 6 months. In the scan results I can take a look at the price graph for each company and know which has been rising consistently and which have been rising in a not-so-straight manner. Is there a formula that can rank the companies by the smoothness / consistency of growth over time?

@Neole, a couple of topics to research related to this are LInear Regression, and Correlation.

Hopefully these will lead you to what you are looking for.

@Neole you are looking for two different measures and a method to combine them. You want "rising" stocks and you want a measure of the "smoothness/consistency".

For "rising" one obvious choice would be momentum (rate-of-change) though you could of course use others.

For "smoothness/consistency" I interpret that as volatility. You could look at the Historical Volatility, the Standard Deviation, the Average True Range etc etc

The number of methods of combining the two are only limited by your imagination. But one effort was made by Perry Kaufman who published in his book Smarter Trading back in 1995, was the Efficiency Ratio (later often referred to as the Fractal Efficiency).

He wrote that the efficiency of a trend is calculated by dividing the net movement over a certain time period (I think in the book he initially used 30 trading days, pages 134-138), divided by the summation of the absolute value of the day-to-day price changes over the same time period. Later he used that ratio to help develop an adaptive smoothing constant which he used in his Kaufman Adaptive Moving Average (KAMA). This happens to be included as a standard indicator in AmiBroker,

https://www.amibroker.com/guide/afl/ama.html

And so for completeness the afl formulation of the Efficiency Ratio would be something like,

```
dir=abs(close-ref(close,-30));
vol=sum(abs(close-ref(close,-1)),30);
ER=dir/vol;
```

As an aside Markos Katsanos wrote an article comparing a few of these similar measures (R-Squared, VHF, ADX, ER) just as "trend" following measures and you can find all the afl's from that article here, (though IMHO @markos should have included his own "Congestion Index" which I think improves upon all of them).

Thanks snoopy, I am looking at the topics. A quick look did not exacty give me what I want, but I will check further.

If I could get Standard Deviation of prices from the trendline (or scatter), maybe that could show me straightness? But I cannot figure out how to put that in a formula.

Portfoliobuilder, I think the efficiency ratio may give me what I need. I will try it out with different equities and check!

Wow the afl formula you gave works uncannily good! Probably as good as I can spot with my own eyes (or better). It's such a simple yet brilliant calculation!