# MaxPositions on Multisystem AFL

Hey guys,

after searching the net, the manual and of course this forum, I still can't fix my problem, as I'm to much a greenhorn obviously...
I'm building a formular for multiple systems, I want to backtest together. For reasons I have to set MaxOpenPositions per System. The Setting MaxOpenPositions doesn't work for me, because one of those systems would use kind of all those Slots, so the others couldn't.

As you can see I want to save the number of open positions per system and check against this number, so system 1 and 2 only use 10 pos., while system 3 only has 5 slots for example.

Maybe I completely overseen something in the manuel. Can anybody help me? Thanks a lot!

``````npos1;
maxpos1 = 10;
npos2;
maxpos2 = 10;
npos3;
maxpos3 = 5;

//(Some Buying and selling rules over here....)

Sell = 0;

for( i = 0; i < BarCount; i++ )
{
{
case 0: // not in trade
if( Buy1[ i ] AND npos1 < maxpos1 )
{
if (npos1 == 0)
npos1 = 1;
else
npos1 = npos1 + 1;
}
else
if( Buy2[ i ] AND npos2 < maxpos2)
{
if (npos2 == 0)
npos2 = 1;
else
npos2 = npos2 + 1;
}
if( Short3[ i ] AND npos3 < maxpos3)
{
InTrade = Short[ i ] = 3;
if (npos3 == 0)
npos3 = 1;
else
npos3 = npos3 + 1;
}

break;

case 1: // in trade mode 1
if( Sell1[ i ] )
{
if (npos1 > 0)
npos1 = -1;
}
break;

case 2: // in trade mode 2
if( Sell2[ i ] )
{
if (npos2 > 0)
npos2 = -1;
}
break;

case 3: // in trade mode 3
if( Cover3[ i ] )
{