PureBytes Links
Trading Reference Links
|
From: "Earl Adamy" <eadamy@xxxxxxxxxx>
>>I'm having a problem compiling some code and am totally stumped. Both
functions are compiled with Auto Detect resulting in type Series....<<
This touches a very important distinction between series and simple user
functions.
All series user functions get "pulled out" of their calling program and are run
BEFORE the calling program is entered. This is required as a way to guarantee
that the series user function will be called on EVERY bar, regardless on the
logic contained within the calling environment. The only way this can be
accomplished is to require all inputs to the series user function be known a
priori. Therefore, series user functions cannot allow as inputs any variables
defined and evaluated within the immediate calling environment, because these
variables would be evaluated AFTER the series function would have already been
called.
The reason why method #3 works is because both user functions are "pulled out"
from the calling environment and evaluated together, prior to executing the
rest of the code in the calling environment.
On the other hand, a type-SIMPLE user function will allow input variables to be
defined within the immediate calling environment because type simple functions
are not "pulled out" of the calling module. The reason is because type simple
functions are not expected to run on every bar, because they generally process
non-time series data. An example of a type simple function would be
SQUAREROOT.
The great aspect to simple functions is that they can also process time series
data, permitting the developer to "work around" the limitations of type series
user functions. This is how I was able to create a type simple RSI user
function. It can have its "length" parameter change on every bar. Works
great.
- Mark Jurik
********************************************
Tools for financial data preprocessing
Jurik Research http://www.jurikres.com/
********************************************
|