Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 15,499 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? #453206
07/12/15 03:27
07/12/15 03:27
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
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:

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? [Re: Mithrandir77] #453233
07/13/15 07:17
07/13/15 07:17
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
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

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? [Re: jcl] #453236
07/13/15 09:29
07/13/15 09:29
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
==

Re: BUG when using msgs in EXITRUN, giving more AR and Sharpe Ratio? [Re: Mithrandir77] #453243
07/13/15 17:07
07/13/15 17:07
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Oh my bad, the bug was in my code. Sorry...


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1