BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio?

Posted By: Mithrandir77

BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? - 07/12/15 03:27

I think I found an strange bug, if I run this code:
Code:
function MAMA1_Strat(var fastLimit,var slowLimit)
{
	BarPeriod = 480;
	vars Price = series(price());	
	Stop = 2*ATR(100);		
	MAMA(Price,fastLimit,slowLimit);
	vars MAMAs = series(rMAMA);
	vars FAMAs = series(rFAMA);
	
	if( crossUnder(FAMAs,MAMAs) ){		
		reverseShort(1);
	} else if( crossOver(FAMAs,MAMAs) ) {		
		reverseLong(1);
	}
	plot("price",Price[0],MAIN|LINE,BLACK);
	plot("Mama",MAMAs,LINE,RED);
	plot("Fama",FAMAs,LINE,BLUE);
}
function run()
{
	StartDate = 2009;//2003
	EndDate = 2014;//2008			
	NumSampleCycles = 5;	
	
        MAMA1_Strat(0.05,0.5);
        //MAMA2_Strat(0.05,0.5);
	//Shannon1_Strat();
	//Shannon2_Strat();
 	static var maeLosingTrades = 0;
	static var maeWinningTrades = 0;
	for(all_trades){
		if (TradeIsClosed)
			if (TradeProfit < 0 and TradeMAE > maeLosingTrades)
				maeLosingTrades = TradeMAE / PIP;
			else if (TradeProfit >= 0 and TradeMAE > maeWinningTrades)
				maeWinningTrades = TradeMAE / PIP;
	}
	
	
	set(LOGFILE); // log all trades	
        if (is(EXITRUN) and SampleCycle = 5){	
		msg("maeLosingTrades: %f",maeLosingTrades);
		msg("maeWinningTrades: %f",maeWinningTrades);
        }
}



Zorro runs but apparently it hangs in Cycles 1 to 4, then I see the progress of Cycle 5 and I get this result:


but if I comment out these lines:
Code:
if (is(EXITRUN) and SampleCycle = 5){	
		msg("maeLosingTrades: %f",maeLosingTrades);
		msg("maeWinningTrades: %f",maeWinningTrades);
}


I see Zorro progressing through the 5 cycles and I get this result:
Posted By: jcl

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? - 07/13/15 07:17

Look into this line:

if (is(EXITRUN) and SampleCycle = 5)

What is the most frequent mistake by programmers, me included, when they attempt to compare something in an if statement? wink
Posted By: boatman

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? - 07/13/15 09:29

==
Posted By: Mithrandir77

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? - 07/13/15 17:07

Oh my bad, the bug was in my code. Sorry...
© 2024 lite-C Forums