Re: [amibroker] Re: statistical volatility function

 

Sorry, you are correct!  My mistake... -Alan

On 3/10/2016 7:09 PM, 'U.Mutlu' um4711@mutluit.com [amibroker] wrote:
 

The formula uses the correct method. Volatility is usually calculated
exactly like in the code: stddev over the ln's...

And the following relation is also true:
ln(y / x) == ln(y) - ln(x)

Alan alan@thenorthams.us [amibroker] wrote on 03/10/2016 10:37 PM:
> U.Mutlu: The equation you are using to calculate Historical Volatility is not
> correct. In your equation you are, in effect, taking the natural log of the
> natural log of the array. Historical Volatility only takes the natural log of
> the array. The function StDev(array,period) already takes the natural log of
> the array so it is incorrect to include it as part of the array. -Alan
>
> On 3/10/2016 3:02 PM, 'U.Mutlu' um4711@mutluit.com [amibroker] wrote:
>>
>> I think of all the presented functions here (btw many thx to all),
>> the function in the original posting seems to be the most accurate one
>> as sometimes the difference can be about a whoppy 1%...
>> Here's an extended and optimized version of it:
>>
>> function my_vola(APriceArr, APeriod, ADaysInYear)
>> { // DaysInYear should be 252 for stocks
>> return StDev(ln(APriceArr) - ln(Ref(APriceArr, -1)), APeriod)
>> / sqrt(1 / ADaysInYear) * 100;
>> }
>>
>> rosenberggregg@yahoo.com [amibroker] wrote on 03/10/2016 05:16 PM:
>> > Hi, it's not built in. Below is the function I use. It's a little more
>> flexible than yours and will be quicker because it uses the built-in ROC
>> function instead of looping. You can add in ln yourself to wrap the ROC.
>> >
>> > function Volatility_afl(watchListName, sourceArray, measurePeriod,
>> reportPeriod) { //begin Volatility
>> > //Calculates volatility over a measuring period and reports it back scaled
>> to reporting period
>> >
>> > dailyChg = ROC(sourceArray, 1, true);
>> > result = StDev(dailyChg, measurePeriod)*sqrt(reportPeriod);
>> >
>> >
>> > return Nz(result);
>> > } //end Volatility
>>
>>
>

__._,_.___

Posted by: Alan <alan@thenorthams.us>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (14)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? The Yahoo Mail app is fast, beautiful and intuitive.

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv