Here is an example script based on the Luxor example script.

The commented out entry condition cause an error of the for(open_trades) loop. The TradeProfit keyword cause this error. Why?
The riskVal increases in this example code. Why?
Any comment is appreciated. Thanks.
Regards, Opentrades

script:
// Luxor system by Jaeckle/Tomasini /////////////
// Make a system profitable by creative selection
// of start and end date

function run()
{
StartDate = 2004;
EndDate = 2015;
BarPeriod = 30;
LookBack = 30;
asset("GBP/USD");

// no trade costs...
Spread = 0;
Slippage = 0;
RollLong = RollShort = 0;

vars Price = series(priceClose()),
Fast = series(SMA(Price,3)),
Slow = series(SMA(Price,30));

static var BuyLimit,SellLimit,BuyStop,SellStop;

if(crossOver(Fast,Slow)) {
BuyStop = priceHigh() + 1*PIP;
BuyLimit = priceHigh() + 5*PIP;
}
if(crossUnder(Fast,Slow)) {
SellStop = priceLow() - 1*PIP;
SellLimit = priceLow() - 5*PIP;
}

if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit)
enterLong(2,BuyStop,2*ATR(20));
// if(TradeProfit>0&&NumOpenLong>0 && Fast[0] > Slow[0] && Price[0] < BuyLimit)
// enterLong(2,BuyStop,2*ATR(20));
if(!NumOpenShort && Fast[0] < Slow[0] && Price[0] > SellLimit)
exitLong(0,0,1);
if(NumOpenLong>3 && Fast[0] < Slow[0] && Price[0] > SellLimit)
exitLong();
var val = 0;
string CurrentAsset = Asset;
for(open_trades)
if(strstr(Asset,CurrentAsset) && TradeIsOpen && !TradeIsPhantom)
val += TradeResult;


PlotWidth = 1000;
PlotBars = 800; // plot all
plot("Risk", RiskVal,NEW,GREEN);
plot("nLong", NumOpenLong,NEW,GREEN);
plot("value", val,NEW,GREEN);
}