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

[amibroker] Re: Z score - Runs Test


  • Date: Mon, 14 Dec 2009 19:49:14 -0000
  • From: "dubi1974" <gonzales74@xxxxxxxxx>
  • Subject: [amibroker] Re: Z score - Runs Test

PureBytes Links

Trading Reference Links

I think I made it (is this right?):

SetOption("UseCustomBacktestProc", True );
SetCustomBacktestProc("",True);

if( Status("action") == actionPortfolio ) // point to correct iteration of backtest engine
{
	//initialize custom backtest engine
	//bo is backtestobject
	
	bo = GetBacktesterObject();
	
	bo.Backtest(); // run default backtest procedure
	st = bo.GetPerformanceStats(0); // get stats for all trades
	totalLossTrades = totalWinTrades = totalRuns = 0;
	for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
    {	//  Loop through all closed trades
        if (trade.GetProfit() > 0)	//  If this was a winning trade
        {
			if (totalWinTrades == 0) totalRuns++;
            totalWinTrades++;
			totalLossTrades = 0;			
        }
		if (trade.GetProfit() < 0)	//  If this was a winning trade
        {
			if (totalLossTrades == 0) totalRuns++;
            totalLossTrades++;
			totalWinTrades = 0;
        }
		
    }	//  End of for loop over all trades

	
	
	N = st.GetValue("AllQty");
	R = totalRuns;
	WIN = st.GetValue("WinnersQty");
	LOSS = st.GetValue("LosersQty");
	X = 2 * WIN * LOSS;
	Z_Score = (N*(R-0.5)-X)/SQRT((X*(X-N))/(N-1));
	
	
	bo.AddCustomMetric( "Z-Score",Z_Score );
	bo.AddCustomMetric( "totalRuns",totalRuns );
}



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/