I don't have this problem when I try it. The included variable works fine across the custom backtest code.
However, there are a few problems with the custom backtest code you've shown here. Firstly there's no actual backtest performed, and secondly you can't write to the Trade object's "Shares" property as it's read-only (although the help doesn't actually tell you that). By including the PreProcess method you've indicated you're going to use the mid-level (or low-level) interface, in which case you need a matching PostProcess method call and a call to ProcessTradeSignals at each bar. If you only want to use the high-level interface, replace the PreProcess method with the Backtest method. Regards, GP --- In [email protected], "dralexchambers" <[EMAIL PROTECTED]> wrote: > > I have an include file which contains some variables for use in my > backtest, eg: > > <INCLUDE FILE> > myvar = 1; > </INCLUDE FILE> > > My backtest AFL is as follows: > > #include <INCLUDE FILE.afl>; > (rest of file....) > > This works fine and the backtest AFL uses myvar correctly when NOT > using the custom backtester. > > However, if I add the Custom Backtester code - below - I get the > following error: > > "Variable 'myvar' used without being initialized" > > It seems the Custom Backtester ignores include files. > > What can I do here as I am stuck? > > --------------------------------- > > SetCustomBacktestProc(""); > if( Status("action") == actionPortfolio ) > { > bo = GetBacktesterObject(); > > bo.PreProcess(); > > for( trade = bo.GetFirstTrade(); trade; trade = > bo.GetNextTrade() ) > { > if (trade.Shares > 10) > { trade.Shares = 20; } > } > } >
