I'm trying to adapt the grid algo to trade several assets and have tried looping the assets and calling the assets, but can't get it to work. This is the standard grid algo:

Code:
bool findTrade(var Price,var Grid,bool IsShort) 
{
  for(open_trades)
    if((TradeIsShort == IsShort)
      and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2))
        return true;
  return false;
}
  
function run() 
{
  BarPeriod = 1440;
  Hedge = 2; 
  EntryTime = ExitTime = 500;  
  var Price;
  var Grid = 100*PIP; // grid spacing
  var Current = priceClose();

  for(Price = 0; Price < Current+5*Grid; Price += Grid) {
    if(Price < Current-5*Grid)
      continue;
    if(Price < Current and !findTrade(Price,Grid,true))
      enterShort(0,Price,0,Grid);      
    else if(Price > Current and !findTrade(Price,Grid,false))
      enterLong(0,Price,0,Grid);
  }
}



How do I get it to trade several assets?

Also, is it possible to set a grid entry or stop loss or take profit as a % of current price? If so, how?

Thanks for the help!!