For about 2 week's i was styding Custom BackTester Interface. 
Everything is perfect, and i got only problem: it is very slow on my 
notebook. I have spent hours looking for error in my code, but even 
with simpliest EMA Crossover system, perfomance of CBI is awful. 

For backtest i've used currencies, 1Minute data, about 200 days. Or: 
200*1440 = 288000 bars. 

There is 2 custom backtest procedures next, both are very slow:

SetCustomBacktestProc("");
if (Status("action") == actionPortfolio)
{
    bo = GetBacktesterObject();//  Get backtester object
    bo.PreProcess();//  Do pre-processing
    for (i = 0; i < BarCount; i++)//  Loop through all bars
    {
        for (sig = bo.GetFirstSignal(i); sig; sig = 
bo.GetNextSignal(i))
        {//  Loop through all signals at this bar
        }//  End of for loop over signals at this ba
        bo.HandleStops(i);//  Handle programmed stops at this bar
        bo.UpdateStats(i, 1);//  Update MAE/MFE stats for bar
        bo.UpdateStats(i, 2);//  Update stats at bar's end
    }//  End of for loop over bars
    bo.PostProcess();//  Do post-processing
}

This was an a template, which do nothing. And it work's slow. 

SetCustomBacktestProc("");
if(Status("action") == actionPortfolio)
{
        bo = GetBacktesterObject();
        bo.Backtest(True);
        SumProfits = bo.InitialEquity;
   dt = DateTime();
                for(bar = 1; bar < BarCount; bar++)
                {
                        SumProfits[bar] = SumProfits[bar - 1];
                                for(trade = bo.GetFirstTrade(bar); 
trade; trade = bo.GetNextTrade(bar))
                                {
                                        ExitDate = trade.ExitDateTime;
                                                if(ExitDate==dt[bar]) 
                                                { 
                                                        
SumProfits[bar] = SumProfits[bar] + trade.GetProfit(); 
                                                }
                                }
                        if(bar == BarCount-1)
                        {
                                for(trade = bo.getFirstOpenPos(); 
trade; trade = bo.getNextOpenPos())
                                {
                                SumProfits[bar] = SumProfits[bar] + 
trade.GetProfit();
                                }
                        }
                }
        bo.ListTrades();
        AddToComposite(SumProfits,"~ClosedEquity","X", 
atcFlagEnableInPortfolio|atcFlagEnableInBacktest|
atcFlagEnableInExplore|atcFlagDefaults);
}

This one plots an a equity curve (availible during backtest) which i 
want to use for position sizing based on % equity in the past. 

btw: notebook is IBM R52 (Intel P M 750 (1,86ghz, 2m L2 Cashe), 512 
ram and ide hard disk)

Without CBT it work's very very fast. But as soon as i begin to work 
with CBT perfomance falls down. 

Somebody has any ideas on the thing? 

Reply via email to