|
Group trades by parameters
#478318
10/01/19 19:15
10/01/19 19:15
|
Joined: Oct 2019
Posts: 3
filip
OP
Guest
|
OP
Guest
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:
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):
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]
#478320
10/01/19 20:25
10/01/19 20:25
|
Joined: Oct 2019
Posts: 3
filip
OP
Guest
|
OP
Guest
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: 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]
#478323
10/02/19 21:00
10/02/19 21:00
|
Joined: Oct 2019
Posts: 3
filip
OP
Guest
|
OP
Guest
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: 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: for(all_algos)
{
print(TO_REPORT, "\n%s", Algo);
for(all_trades)
{
continue;
}
}
|
|
|
|