StaticVarAdd
|
Miscellaneous functions |
SYNTAX | StaticVarAdd( "name", value, keepAll = True, persistent = False ) |
RETURNS | NOTHING |
FUNCTION | StaticVarAdd implements an atomic addition (interlocked read-add-write) operation for static variables.
It is multithreading safe addition for static variables that are shared by multiple threads. This function is atomic with respect to calls to other static variable functions.
KeepAll flag when it is set to true emulates the behavior of AddToComposite. It keeps all values that are already present, so if data holes exists in current symbol,the bars that are present in static variable but not present in current symbol remain untouched. When KeepAll is set to false then only bars that are present in current symbol are kept. Any other bars that were present in static variable but not present in currently processed symbols are removed. That is what normally happens with StaticVarSet().
In fact when KeepAll is set to False, StaticVarAdd can be seen as the following pseudo code:
The function can be used to create composites like shown in the example below. NOTES:
|
EXAMPLE | if( status("stocknum")
== 0 ) |
SEE ALSO | StaticVarSet() function , StaticVarGet() function , StaticVarCompareExchange() function |
The StaticVarAdd function is used in the following formulas in AFL on-line library:
See updated/extended version on-line.