Log is natural logarithm, Log10 is decimal, was: Log(number) function precision

I am trying to duplicate the output of this AB code in Excel.

	_SECTION_BEGIN("Historic Volatility");
		HVlookBack = 100; 
		HV = Prec(StDev(log(C/Ref(C,-1)),HVlookBack )*100*sqrt(252),2);
	_SECTION_END();

Right now I am trying to just duplicate the log(C/Ref(C,-1)) snip specifically using the Explorer. In AB I get the output of -0.0100 and in Excel I get -0.0043398.
I think I am getting the same answer, and it may just be a rounding issue in the AB Explorer via some setting I am not aware of. I thought the Prec function might be the key, but that had no effect.

Can anyone see what I might be doing wrong?

Excel...
image

AmiBroker...
image

//EXPLORATION CODE
if (status( "action" ) == actionExplore)
{
Filter = 1; 
AddColumn ( Prec(log(177.24/179.02),4), "LOG test" , 1.4);
}

Please carefully read the AB manual.
It's pretty clearly documented that AB log is natural logarithm.

8

So in Excel use LN.

9


Equivalent to Excel LOG in AB it is log10 function.

9


Please also read here for further questions.

3 Likes

Yeah I did read the manual, but I am not mathematically astute enough to know the difference in Excel between LOG and LN functions. Thank you for pointing me to the right function in Excel.

For what it is worth, Excel LOG function takes TWO arguments, second argument is logarithm BASE. It just happens that if you don't supply second argument in Excel, it defaults to 10, see: https://exceljet.net/excel-functions/excel-log-function

Excel also has LOG10 function which takes one argument.

In AmiBroker Formula Language exactly as in "C" programming language, log is natural logarithm and log10 is decimal.

AmiBroker Users' manual:
http://www.amibroker.com/f?log
http://www.amibroker.com/f?log10

C++ reference
http://www.cplusplus.com/reference/cmath/log10/
http://www.cplusplus.com/reference/cmath/log/

3 Likes

Thank You Tomasz. I appreciate your insight!