Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 973 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Get Data from internal functions, eg plotMAEGraph #462819
10/30/16 18:26
10/30/16 18:26
Joined: Aug 2016
Posts: 61
D
dr_panther Offline OP
Junior Member
dr_panther  Offline OP
Junior Member
D

Joined: Aug 2016
Posts: 61
I wonder how I could get the data which is used to do some graphs like
plotMAEGraph. I was thinking if there is a simple possibility to get it as csv for example.

I could visualize to track the status of each trade in a variable and write it into a file at the close, but is there a more elegant way?

Re: Get Data from internal functions, eg plotMAEGraph [Re: dr_panther] #462821
10/30/16 18:39
10/30/16 18:39
Joined: Aug 2016
Posts: 61
D
dr_panther Offline OP
Junior Member
dr_panther  Offline OP
Junior Member
D

Joined: Aug 2016
Posts: 61
Just found the solution: the profile.c has all the code:



Code:
void plotMAEGraph(int bars)
{
	if(!is(TESTMODE)) return; 
	g->dwStatus |= PLOTSTATS;
	if(is(EXITRUN))
	{
		if(!bars) bars = 50;
	
		var vMaxMAE = 0;
		for(all_trades) // calculate maximum MAE in pips
			vMaxMAE = max(vMaxMAE,TradeMAE/PIP);
		//printf("\nMaxMAE: %.0f",vMaxMAE);
	
		var vStep;
		if(bars < 0) // bucket size in pips
			vStep = -bars;
		else
			vStep = 10*(int)max(1.,vMaxMAE/bars/10);
		printf("  Step: %.0f",vStep);
		
		for(all_trades) 
		{
			var vResult = toPIP(TradeResult);
			var vMAE = TradeMAE/PIP/vStep;
			int n = floor(vMAE);
			plotBar("Profit",n,n*vStep,0,AVG|BARS|LBL2,COLOR_DEV);
			if(vResult > 0)
				plotGraph("Win",vMAE,vResult,DOT,GREEN);
			else
				plotGraph("Loss",vMAE,vResult,DOT,RED);
		}
	}
}



Which leads to the next question: does someone have written more graph functions and is willing to share them?

Last edited by dr_panther; 10/30/16 19:24.
Re: Get Data from internal functions, eg plotMAEGraph [Re: dr_panther] #462824
10/31/16 01:21
10/31/16 01:21
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Here's one that I use to plot Sharpe ratios from different cycles with the same script.

An example of where I use this is in machine learning research where the learning algorithm has a non-deterministic component (for example, the initial weights of a neural network), and I want to test the stability of performance. Also, if you set the BALANCED argument of adviseLong(), Zorro can generate different training data for your machine learning models in each training run. Testing them over several cycles can help assess the stability of the model.

Code:
void plotSharpeCycles() // calculate sharpe ratio of individual trade cycles via Welford algorithm
{
	if(is(EXITRUN)) 
	{
		var n = 0;
		var mean = 0;
		var M2 = 0;
		var delta;
		var variance = 0;
		for(all_trades)
		{
			n += 1;
			delta = TradeProfit - mean;
			mean += delta/n;
			M2 += delta*(TradeProfit - mean);
			variance = M2/(n-1);			
		}
		var sharpe = sqrt(252)*mean/sqrt(variance);
		plotBar("",TotalCycle,TotalCycle,0,SUM|BARS|LBL2,BLUE);
		plotGraph("Sharpe",TotalCycle,sharpe,LINE,RED);
	}
}



Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1