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
2 registered members (degenerate_762, Nymphodora), 1,012 guests, and 3 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
Group trades by parameters #478318
10/01/19 19:15
10/01/19 19:15
Joined: Oct 2019
Posts: 3
F
filip Offline OP
Guest
filip  Offline OP
Guest
F

Joined: Oct 2019
Posts: 3
Hello everyone, I am developing mean-reversion script on 4 FX pairs (strategy is always one currency long and one currency short). The script relies on 2 parameters and I would like to group trades by these parameters so that I can calculate information ratio for each of the parameter combinations. I am doing this using evaluate() and I found interesting behaviour:

Code
        for(all_algos)
        {
		int algocount = 0;
		
		for(all_trades)
		{
			algocount++;
		}
		
		print(TO_REPORT, "\n%d", algocount);
	}


Produces the correct total number of trades (multiple times). However, I would also except that this gives the same (only once):

Code
	int algocount = 0;
	for(all_algos)
	{
		for(all_trades)
		{
			if(TradeAlgo == Algo)
			{
			algocount++;
			}
		}
	}
	print(TO_REPORT, "\n%d", algocount);


The number produced is the total number of long trades only. Is this behaviour intended? How could I achieve the grouping of all trades?
Thanks a lot.

Re: Group trades by parameters [Re: filip] #478319
10/01/19 19:37
10/01/19 19:37
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Post your entire script.

Re: Group trades by parameters [Re: filip] #478320
10/01/19 20:25
10/01/19 20:25
Joined: Oct 2019
Posts: 3
F
filip Offline OP
Guest
filip  Offline OP
Guest
F

Joined: Oct 2019
Posts: 3
The trading logic is from RobotWealth FXbootcamp, so I am not sure if I can post it here. I think this should be reproducible on any strategy that trades different assets and params. Basically I am doing this:

Code
trade_function(some params, param_1, param_2);
algo(strf("lb_%d_re_%d", param_1, param_2);


trade_function cycles through the pairs and selects the ones for trading orders enterShort(), enterLong().

Re: Group trades by parameters [Re: filip] #478322
10/02/19 13:03
10/02/19 13:03
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Well, without looking at your full script:
* How do you even know that you are only counting the long trades? I see no use of TradeIsLong. Isolate, isolate, isolate.
* I suggest printing detailed information about every trade for debugging purposes.

https://zorro-project.com/manual/en/fortrades.htm
https://zorro-project.com/manual/en/trade.htm

Re: Group trades by parameters [Re: filip] #478323
10/02/19 21:00
10/02/19 21:00
Joined: Oct 2019
Posts: 3
F
filip Offline OP
Guest
filip  Offline OP
Guest
F

Joined: Oct 2019
Posts: 3
I did some experiments and found that this approach is not right. You can not simply nest the all_algos loop with the all_trades loop. (as these loops are not documented, they should not be used in other way than the official examples) Returning back to the original goal: Grouping trades by params can be for example achieved just by using all_trades and TradeVars. See the two examples, why the nesting approach is flawed:

Code
	for(all_algos)
	{
		for(all_trades)
		{
			print(TO_REPORT, "\n%s", Algo);
		}
	}
}


Does not produce output with multiple algo names. It is just stuck on one. Whereas this code does it:

Code
	for(all_algos)
	{
		print(TO_REPORT, "\n%s", Algo);
		for(all_trades)
		{
			continue;
		}
	}

Re: Group trades by parameters [Re: filip] #478324
10/02/19 22:23
10/02/19 22:23
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Well, you are swimming in dangerous waters... From the manual: "The above enumeration loops are macros defined in include\variables.h. Unlike a normal for loop, enumeration loops cannot be nested, and they must not be aborted by break or return statements. The break_trades macro can be used to abort trade loops. "

A better approach might be to write a new macro from scratch, not using the predefined ones in order to avoid unpredictable behaviors...


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