Ok, so I have this code now, but I don't have the "findTrade" function comparing the asset yet:

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 tradeGrid ()
{
  var Price;
  var Grid = 100*PIP;
  var Current = priceClose();
  EntryTime = ExitTime = 500; 

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);
  }
 
function run() 
{
  BarPeriod = 1440;
  Hedge = 2; 

while(asset(loop("SPX500","US30")))
while(algo(loop("GRD")))
  {
    if(Algo == "GRD") 
      tradeGrid();
  }
}



What's the code for the "findTrade" function to compare the asset? I can't figure that out.
Does the "findTrade" function stay where it is?

Regarding grid as percent of price, a variable grid is exactly what I want. I've played around with grids based on ATR, which suits my purposes, but I want to play around with variable grids based on percent of price as I'm looking at this as more of an investment tool to trade indexes. If it's possible, how would I set the grid based on percent of price?

Many thanks!