- expand time frame compressed array

Time Frame functions
(AmiBroker 4.50)

SYNTAX TimeFrameExpand( array, interval, mode = expandLast )
FUNCTION The TimeFrameExpand function expands time-compressed array from interval time frame to base time frame (interval parameter must match the value used in TimeFrameCompress or TimeFrameSet)

The TimeFrameExpand is used to decompress array variables that were created in different time frame. Decompressing is required to properly display the array created in different time frame. For example if you want to display weekly moving average it must be 'expanded' so the data of one weekly bar covers five daily bars (Monday-Friday) of corresponding week.

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)).

Caveat: expandFirst used on price different than open may look into the future. For example if you create weekly HIGH series, expanding it to daily interval using expandFirst will enable you to know on MONDAY what was the high for entire week.

For more information check Tutorial: Multiple time frame support

EXAMPLE wc = TimeFrameCompress( Close, inWeekly );

/* now the time frame is still unchanged (say daily) and our MA will operate on daily data */
dailyma =
MA( C, 14 );

/* but if we call MA on compressed array, it will give MA from other time frame */
weeklyma =
MA( wc, 14 ); // note that argument is time-compressed array

Plot( dailyma, "DailyMA", colorRed );

weeklyma =
TimeFrameExpand( weeklyma, inWeekly ); // expand for display

Plot( weeklyma, "WeeklyMA", colorBlue );
SEE ALSO TimeFrameSet() function , TimeFrameRestore() function


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

More information:

See updated/extended version on-line.