For comparing the asset:

Code:
if((TradeIsShort == IsShort)
      and strstr(TradeAsset,Asset)
      and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2))
...



and the 'Algo' comparison and second while loop is not needed when you have only one algo.

For a variable grid, you could for instance set the grid distance to 0.1% of price(), or better, to a multiple of ATR().