|SYNTAX||StaticVarGet( ''varname', align = True' )|
|RETURNS||NUMBER or STRING|
|FUNCTION|| Gets the value of static variable.
Static variable - the variable has static duration (it is allocated when the program begins and deallocated when the program ends) and initializes it to Null unless another value is specified. Static variables allow to share values between various formulas. ARRAY static variables are now supported (version 5.30 and above).
Please note that static array variable will consume 8 * (number_of_bars) bytes of memory and it won't be released until program is closed or variable is removed using StaticVarRemove().
Static arrays can be even 100 faster than AddToComposite/Foreign, however these two are not strictly equivalent.
There are following limitations / differences of static arrays as compared to Foreign/AddToComposite:
The default value is True and it means that values stored in static variables are retrieved and aligned to currently selected symbol data/timestamp on each bar basis so data for corresponding date/time stamps match. This is recommended setting and this is the way it worked in previous versions.
When align is switched to False - it means that AmiBroker does not perform any checks nor any alignment and will fill the array with consecutive values stored in static array regardless of their timestamps. If there are less bars in the static array than in the current arrays, the last value of static array will be propagated till BarCount - 1.
It is advised NOT to use align=False, unless you know exactly what you are doing and you are aware that date/time stamps have no meaning in particular variable or in case when date/time stamps are are aligned using your own method.
Note that speed difference between align 'on' and 'off' is usually negligible because alignment algorithm is very fast and has similar complexity as plain memory copy.
|SEE ALSO||StaticVarSet() function , StaticVarSetText() function , StaticVarGetText() function|
The StaticVarGet function is used in the following formulas in AFL on-line library:
Updated on-line reference