Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, Quad, VoroneTZ, 1 invisible), 623 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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