SetBarsRequired
- set number of previous and future bars needed for script/DLL to properly execute

Miscellaneous functions
(AmiBroker 4.10)


SYNTAX SetBarsRequired( backwardref = -1, forwardref = -1 )
RETURNS nothing
FUNCTION set number of previous and future bars needed for script/DLL to properly execute. If your formula is pure AFL you don't need to use this function at all, as AmiBroker automatically calculates number of bars required for all its built-in functions. But if you are using script or a DLL you may need to use this function to make sure that your indicators are properly calculated in QuickAFL mode. Specifying -1 means no change. For example if you are using the script that calculates 100 bar moving average you may need to call SetBarsRequired( 100, 0 ); at the very beginning of your formula. Please note that in most cases it is not necessary (even if you are using script or DLL) because AmiBroker always provides at least 30 past data bars more than needed. Starting from AmiBroker version 5.20 you can use sbrAll (-2) constant to tell AmiBroker to use ALL available bars:
EXAMPLE SetBarsRequired( -2, -2 ); // require ALL past and future bars - this turns OFF quickAFL (v5.20)
SEE ALSO  

References:

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

More information:

See updated/extended version on-line.