[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Execute AFL Once Per Backtest (Not Once Per Symbol)



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "davemabe2000" <davemabe@xxx> 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)?
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/