Gamestudio Links
Zorro Links
Newest Posts
Stooq now requires an API key
by cwford. 10/08/26 23:27
ZorroGPT
by TipmyPip. 10/06/26 05:32
Purchase A8 full licence version
by jcl. 10/05/26 12:12
Respect History setting for Z systems
by AndrewAMD. 10/02/26 15:43
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (cwford, JeyKey II), 23,100 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 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,139
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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