Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TraderTom, Akow), 1,388 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 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: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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 | chip programmers | 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