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

[amibroker] Re: CBT Perfomance?



PureBytes Links

Trading Reference Links

I'm sorry, Tomash. You were right. Two week of attemps to improve 
perfomance of my code maked me too much "emotional". Emotionality is 
not good for trader in any appearance. 

In Future I will use only quantitative statemets.

So, here is the entire code: 

Buy = Cross( Close, EMA( Close, 180 ) );
Sell = Cross( EMA( Close, 180 ), Close );

With this code, backtester executes in "less than one second". 
Because I dont know how I could measure backtesting time, I can only 
use a statement "less than one second" (btw: very very less)

If i will add to this code, at very beginning of the formula, a high -
level CB formula, like this:  

SetCustomBacktestProc("");
if(Status("action") == actionPortfolio)
{
	bo = GetBacktesterObject();
	bo.Backtest();
	SumProfits = bo.InitialEquity;
	dt = DateTime();
		for(bar = 1; bar < BarCount; bar++)
		{
			SumProfits[bar] = SumProfits[bar - 1];
				for(trade = bo.GetFirstTrade(); 
trade; trade = bo.GetNextTrade())
				{
					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();
				}
			}
		}
	AddToComposite(SumProfits,"~ClosedEquity","X", 
atcFlagEnableInPortfolio|atcFlagEnableInBacktest|
atcFlagEnableInExplore|atcFlagDefaults);
}


In this case, backtest takes "more than 5 minutes". Any way i think 
that is not neccessary to provide precize timing's here, because the 
difference is:

300 seconds vs. very very less than 1 second

And If I will need to do an a simply optimization? 300 second x 300 
passes?

I'm not an a AFL programmer for year's, so there could be some 
logical error, which couldn't be found with "syntax verifier" or my 
mind.

Anycase i'm looking to implement position sizing which refers to 
equity values in the past. Which with some modifications i'll can 
applicate to any system i'll develop in the future. 

Also i'm looking to add a column to backtester results list, in 
which, i will have the sum of spread i have paid for one trade.

This all refers only to currencies trading and 1Minute interval 

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> 
wrote:
>
> Hello,
> 
> "Very slow", "awful" are qualitive not quantitative statement. 
> In fact it does not say anything.
> 
> Quantitative statement would be that it is four times slower or ten 
times slower.
> 
> You don't provide that, so it is hard to help you, if we don't know
> what you mean. Of course LOW-level CBI by nature would be slower
> than mid-level CBI, which in turn will be slower than high-level CBI
> which is slower than built-in backtest routines.
> 
> The differences however are not "awful". They are perfectly 
adequate.
> High-level CBI is just few percent slower. Mid-level can be 50% 
slower than
> built-in (I am speaking about core overhead). 
> 
> First answer yourself a question:
> WHY do you use custom backtester for EMA crossover?
> Using hammer to kill a fly?
> 
> Second thing is that you are using LOW-LEVEL backtester mode
> which is the slowest.
> 
> 90% of systems can be written without custom backtester at all.
> 99% of systems can be written WITHOUT using low-level custom 
backtester.
> 
> > want to use for position sizing based on % equity in the past. 
> % Equity ? 
> Why dont you use SetPositionSize  function with spsPercentOfEquity 
mode instead?
>  http://www.amibroker.com/f?setpositionsize
> 
> It does not require custom backtester at all.
> 
> And you definitely don't need LOW-level CBI to use equity-feedback.
> Medium level is perfect for ALL equity-feedback scenarios.
> http://www.amibroker.com/guide/a_custombacktest.html
> And it is way faster.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "ifrmd" <ifrmd@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, January 28, 2008 10:09 PM
> Subject: [amibroker] CBT Perfomance?
> 
> 
> > 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? 
> > 
> > 
> > 
> > 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
> > 
> > 
> >
>




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/