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

Re: [amibroker] Formula Issue



PureBytes Links

Trading Reference Links

interval is in seconds
tick bars = 0
5 sec bars = 5
1 min bars = 60
hourly bars = 3600
daily bars = 86400
weekly bars = 432000 
monthly bars = 2160000 (216e4) 

if you are using beta versions
VERY IMPORTANT:
inWeekly constant is now 432001 ( 5*inDaily + 1 ) - in previous
version it was 432000
inMonthly constant is now 2160001 ( 25*inDaily + 1 ) - in previous
version it was 2160000

also the syntax of using IIF is xyz = iif( cond1, 1, 2 );

modified lines are:

timefactor = 
IIf(Interval() == 86400, Daysinyear,
IIf(Interval() == 432000,Daysinyear/Daysinweek,
IIf(Interval() == 2160000,Daysinyear/Daysinmonth,Null)));


On Wed, 16 Feb 2005 12:46:36 -0000, mjarvis999 <mark.jarvis@xxxxxxxxx> wrote:
> 
> 
> 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
> 
> 
> 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
> 
> 
> 
> 
> 


-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/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/