Time Frame functions
|FUNCTION|| The TimeFrameSet replaces current price/volume arrays: open, high, low, close, volume, openint, avg with time-compressed bars of specified interval once you switched to a different time frame all calculations and built-in indicators operate on selected time frame. To get back to original interval call TimeFrameRestore() function. Before calling TimeFrameSet again in the same formula with different interval you have to restore original time frame first using TimeFrameRestore.
interval defines time frame interval in seconds. So 60 means 1-minute. For the convenience the following interval constants are pre-defined:
To get other intervals you can use multiple of pre-defined intervals, for example: ( 3*in1Minute ) gives 3 minute bars. Or you can use 3 * inDaily for 3-day bars.
New in version 4.70 and above: You can also use NEGATIVE values for N-tick charts: -5 fives 5-tick chart. Note that N-tick compression works correct only if you have 1-tick base time interval selected in database settings.
You can also use TimeFrameSet to create N-volume bars as well as Range bars. See TimeFrameMode() function for more details.
Once you switch the time frame using TimeFrameSet , all AFL functions operate on this time frame until you switch back the time frame to original interval using TimeFrameRestore or set to different interval again using TimeFrameSet. It is good idea to ALWAYS call TimeFrameRestore when you are done with processing in other time frames.
When time frame is switched to other than original interval the results of all functions called since TimeFrameSet are time-compressed too. If you want to display them in original time frame you would need to 'expand' them as described later. Variables created and assigned before call to TimeFrameSet() remain in the time frame they were created. This behaviour allows mixing unlimited different time frames in single formula.
Please note that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.
For more information check: Tutorial: Multiple time frame support in AFL
|SEE ALSO||TimeFrameRestore() function , TimeFrameExpand() function , TimeFrameGetPrice() function|
tj --at-- amibroker.com
Buy=Cross( MA(Close,5), TimeFrameExpand(MA10_15Min, in15Minute) );
The TimeFrameSet function is used in the following formulas in AFL on-line library:
See updated/extended version on-line.