Working with bar returns in MQL5

 

Hi,

Sometimes I like to think in daily returns for a security (!)

So for instance, I'd like to know the volatility (standard deviation) of the last year of daily returns of EURUSD.

Unfortunately I cannot find a quick way to get this in MQL5.

iSTD will give me the standard deviation of the PRICE of EURUSD, but that is a different thing.

In theory I could use iMA to get a series of daily returns. Then the problem is there doesn't seem to be mathematical functions for stdev and mean in MQL5, apart from iStd and iMA which are rather different!

Of course, one could always do a cumbersome procedure such as get all the daily close prices in an array, loop through the array dividing each by predecessor to get the daily returns.

However, surely MQL5 must be better than this!

Any ideas?

 
Then the problem is there doesn't seem to be mathematical functions for stdev and mean in MQL5, apart from iStd and iMA which are rather different!

https://www.mql5.com/en/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathstandarddeviation

https://www.mql5.com/en/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathmean