[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Formula Issue



PureBytes Links

Trading Reference Links


If someone could have a look at this and point out the error, I'd
greatly appreciate it.  I must be going blind.

What I am trying to do is set 'timefactor' depending on the timeframe
I am using (this is hopefully clear from the code).  What is happening
is no matter what I try, timefactor is being set to the last value
(daysinyear/daysinmonth) or 12.167.

If I return "Interval" from the function, it is 86400 (as it should
be).  If I return "indaily" it too is 86400.  I am definitely in daily
mode on the chart..   If I manually set timefactor to 365, the code
works fine, so it must be the iif(interval() ===, etc. that is having
the problem.

function Volatility(Field, Length)
{
Daysinweek = 7;
Daysinmonth = 31;
Daysinyear = 365;

IIf(Interval() == inDaily, timefactor = Daysinyear,
IIf(Interval() == inWeekly,timefactor = Daysinyear/Daysinweek,
IIf(Interval() == inMonthly,timefactor = Daysinyear/Daysinmonth,Null)));

HisVol = StDev(log(Field/Ref(Field,-1)),Length) * sqrt(Timefactor);
return HisVol;
}

Thanks in advance,

Mark





------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/