Interval
- get bar interval (in seconds)

Date/Time
(AmiBroker 4.10)


SYNTAX Interval( format = 0 )
RETURNS NUMBER
FUNCTION Interval() function returns bar interval.

Possible formats:

  • format = 0 - returns bar interval in seconds
  • format = 1 - as above plus TICK bar intervals are returned with negative sign so Interval() function applied to 10 tick chart will return -10
  • format = 2 - returns STRING with name of interval such as "Weekly/Monthly/Daily/Hourly/15-minute/5-tick"

Example time intervals in seconds:
tick bars = 0
5 sec bars = 5
1 min bars = 60 (inMinute constant)
hourly bars = 3600
daily bars = 86400 (inDaily constant)
weekly bars = 432001 (inWeekly constant)
monthly bars = 2160001 (inMonthly constant)

Caveat: it is bad idea to use text comparision like this if( Interval(2) == "Weekly" ) { }. Do NOT do that, because as soon as localized version of AmiBroker arrives, your code will be broken as names will be translated. Use NUMERIC comparison, such as: if( Interval() == inWeekly ) { } instead.

EXAMPLE "Interval in seconds " + WriteVal( Interval() );
SEE ALSO  

References:

The Interval function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.