As indicated in the user guide ( 
http://www.amibroker.com/guide/a_custombacktest.html ), HandleStops and 
UpdateStats are low level interface methods. The behavior of these two methods 
is handled by ProcessTradeSignals at the mid level.

You are effectively performing the same operation twice, which is likely what 
is causing your mystery trades.

Mike

--- In [email protected], Potato Soup <potatoso...@...> wrote:
>
> So I took the template code for a backtest from the user knowledge base 
> article. What I don't understand is why it changes the outcome of my trades 
> even though I have no custom code in it. For instance, before inserting the 
> custom backtest code, my AFL creates 30 trades. But with this added, it 
> creates 34 trades, and 2 of them are on the same day.
> 
> Why would this following code modify the outcome of an AFL backtest:
> 
> SetCustomBacktestProc("");
> if (Status("action") == actionPortfolio)
> {
>     //  Get backtester object
>    bo = GetBacktesterObject();    
> 
>     // o pre-processing
>     bo.PreProcess();
>        
>     // Loop through all bars
>     for (i = 0; i < BarCount; i++)    
>    {
> 
>         // Loop through all signals at this bar
>        for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
>        {    
>             // Process trades at this bar
>             bo.ProcessTradeSignals(i);    
>        }    
> 
>         // Handle programmed stops at this bar
>        bo.HandleStops(i);    
> 
>         // Update MAE/MFE stats for bar
>        bo.UpdateStats(i, 1);    
> 
>         // Update stats at bar's end
>        bo.UpdateStats(i, 2);    
>    }    
> 
>     // Do post-processing
>    bo.PostProcess();    
> }
> ///// End of custom backtesting code
>


Reply via email to