If you're using (or want to use) a custom backtest procedure, then you
can do it like this. In the main code, add something like:

if (Status("action") == 5 && IsNull(StaticVarGet("InitDone")))
{
    StaticVarSet("InitDone", True);
    <your one-time code here>
}

and at the very end of the custom procedure (after the PostProcess
command if you're using the mid or low level interface) add:

StaticVarSet("InitDone", Null);

The status action value of 5 selects only backtests and optimisations.
Essentially this tests if the static variable is undefined (Null) and
if it is, it does the one-time code and defines the variable. That
will then prevent it from executing the one-time code with every other
symbol. After the backtest is complete, ie. at the end of the custom
procedure, the variable is set back to Null ready for the next
backtest run.

Not sure if you can do the same thing without a custom backtest
procedure though, as I don't know if it's possible in the main AFL
code to tell when you're doing either the first or last symbol of the
backtest.

Regards,
GP


--- In [email protected], "davemabe2000" <[EMAIL PROTECTED]> wrote:
>
> Is there a way to have some AFL code execute once just before any
> backtesting is performed?  I've got some AFL that empties a watchlist
> and then fills it with just the symbols I'm testing with (which is
> different for each backtest).
> 
> My AFL works ok, but after looking at DebugView the emptying and
> populating of the watchlist is happening once per symbol, so it ends
> up executing this multiple times.
> 
> Is there a way to use the COM model to execute some AFL code to make
> the watchlist modifications (but not actually perform a backtest)?
>


Reply via email to