- retrieve O, H, L, C, V values from other time frame

Time Frame functions
(AmiBroker 4.50)

SYNTAX TimeFrameGetPrice( pricefield, interval, shift = 0, mode = expandFirst )
FUNCTION The TimeFrameGetPrice - retrieves OHLCV fields from other time frames. This works immediatelly without need to call TimeFrameSet at all.

First parameter - pricefield - is one of the following: "O", "H", "L", "C", "V", "I" (open interest).

Interval is bar interval in seconds. You can use pre-defined interval constants: in1Minute, in5Minute, in15Minute, inHourly, inDaily, inWeekly, inMonthly. Or integer multiples like (3*in1Minute) for 3 minute bars

shift allows to reference past (negative values) and future (positive values) data in higher time frame. For example -1 gives previous bar's data (like in Ref function but this works in higher time frame).

mode - one of available modes:

  • expandLast - the compressed value is expanded starting from last bar within given period (so for example weekly close/high/low is available on Friday's bar)
  • expandFirst - the compressed value is expanded starting from first bar within given period (so for example weekly open is available from Monday's bar)
  • expandPoint - the resulting array gets not empty values only for the last bar within given period (all remaining bars are Null (empty)).

Note these functions work like these 3 nested functions:

TimeFrameExpand( Ref( TimeFrameCompress( array, interval, compress(depending on field used) ), shift ), interval, expandFirst )

therefore, if shift = 0 compressed data may look into the future ( weekly high can be known on monday ). If you want to write a trading system using this function please make sure to reference PAST data by using negative shift value.

The only difference is that TimeFrameGetPrice is 2x faster than nested Expand/Compress.

For more information check Tutorial: Multiple time frame support

EXAMPLE // Example 1. get previous week Open price
TimeFrameGetPrice( "O", inWeekly, -1 )

// Example 2. get weekly Close price 3 weeks ago
TimeFrameGetPrice( "C", inWeekly, -3 )

// Example 3. get weekly High price 2 weeks ago
TimeFrameGetPrice( "H", inWeekly, -2 )

// Example 4. get this week Open price.
TimeFrameGetPrice( "O", inWeekly, 0 )

// Example 5. get previous Day High when working on intraday data
TimeFrameGetPrice( "H", inDaily, -1 )
SEE ALSO TimeFrameSet() function


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

More information:

See updated/extended version on-line.