PureBytes Links
Trading Reference Links
|
David Wieringa <wieringa@xxxxxxxxxx> asks:
>One thing that has been confusing me for some time is the history of a
>function and the function storage...
>
>Let me start by example. What exactly is happening in the following
>function call?
>
> x = MyFunc(a, b, c)[5];
>
>When I asked some questions to Omega a couple of months ago, I was led to
>believe that x would be set to the value that MyFunc generated 5 bars ago -
>and it was retrieved from storage (i.e. it wasn't re-executed).
>...
>So what I am envisioning then, is TS executes all of the functions that are
>referenced by a system or indicator when it moves to a new bar. The inputs
>to these functions are the current values of the variables for that price
>bar. The function results are stored. Then the system/indicator code is
>executed and any reference to a function simply does a lookup (the inputs
>are disregarded in the case of a reference to a function N bars back).
>Then TS moves to the next bar, updates the function values again and then
>executes the code.
That's pretty much it; you can think of virtually everything having a
MaxBarsBack-long flowthrough buffer associated with it. I don't know
if the system is clever enough to not allocate and waste runtime
managing those buffers if no historical references are made.
One subtle gotcha occurs when you have an indicator set to execute
"every tick." The values of your variables are NOT remembered between
calls to your function, so you can't save state information to, for
example, cause only one alert per bar. Values are only updated
at bar boundaries.
Jim
|