I was wondering how built-in "dev" function in Pine is calculated so I made a little research.
I examined 7 samples: 0) "dev" function itself 1) "dev" according to its description: series - sma(series) 2) Mean Absolute Deviation 3) ratio of the absolute difference from 1) divided by period 4) ratio of the difference from 1) divided by period 5) Median Absolute Deviation 6) tricky for-loop to calculate Mean Absolute Deviation
The results of the null and sixth samples are identical.
So, TV built-in "dev" function represents Mean Absolute Deviation and it's description is incorrect.
Where it is used? For example: Commodity Channel Index. You can check its original formula and if you used simple standard deviation instead of MAD in your CCIs - well guys, you were wrong.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publications is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.