Finally decided to to write 2 for-loops to loop through all assets and algos before actually entering trades and increasing a counter in case of an enter signal in any one of them.
After that I looped through again and set Lots = lot_number/count.
This seems to work as intended.
Below a simple strategy to illustrate:
int count;
int lot;
function tradeB(bool trade)
{
Stop = 2*ATR(30);
vars Price = series(priceClose());
LifeTime=1;
if(Price[0]>Price[1]) //simple entry condition
{
if(trade==false) count++; //increase the counter in case of an entry signal
else if(trade==true) //actual entry
{
printf("n %i %i %s %s",lot,count,Algo,Asset);
Lots=lot/count;
enterLong();
}
}
}
function tradeA(bool trade)
{
Stop = 2*ATR(30);
vars Price = series(priceClose());
LifeTime=1;
if(Price[0]>Price[1])
{
if(trade==false) count++;
else if(trade==true)
{
printf("n %i %i %s %s",lot,count,Algo,Asset);
Lots=lot/count;
enterLong();
}
}
}
function run()
{
StartDate = 20150110;
EndDate = 20150120;
BarPeriod = 1440;
set(TICKS);
lot = 100;
count=0;
string assets[2];
assets[0] = "EUR/USD";
assets[1] = "USD/JPY";
int i;
for(i=0;i!=2;i++) //loop to count entry signals
{
asset(assets[i]);
tradeA(false);
tradeB(false);
}
//actual trade entry loop
while(algo(loop("A","B")))
while(asset(loop("EUR/USD","USD/JPY")))
{
// printf("n %i",count);
if(Algo == "A")
{
tradeA(true);
}
if(Algo == "B")
{
tradeB(true);
}
}
}