I have a strategy that trades momentum over a stock universe of some ~200 stocks.
It trades daily bars and has a one year lookback. Some of the stocks have been listed longer than others, e.g. if I run a backtest from 2000, some of the stocks was not listed until 2005, 2010 etc.

My current problem is that sometimes after sorting stocks by momentum, trades are skipped because the one or more of the selected stocks are in a lookback. That is , they have a high momentum, but they were listed less than a year ago.

I have tried adding some
Code:
if(is(LOOKBACK))

logic to the script, but it doesn´t seem to help. I guess this LOOKBACK variable is for the entire script, and not per asset? Can I somehow exclude assets that are still in their lookback period from my momentum calculations?

Code:
//Find composite momentum
		while(loop(Assets))
		{
			asset(Loop1);
			exitLong();
			
                        //This is my attempt to exclude stocks in lookback
			if(is(LOOKBACK)) {
				printf("nCurrently in lookback %s", Asset);
				asset_num++;
				continue;
			}
			
			var mom12 = (priceClose(TRADING_DAYS_1_MONTH) - priceClose(TRADING_DAYS_12_MONTH)) / priceClose(TRADING_DAYS_12_MONTH);
			var mom6 =  (priceClose(TRADING_DAYS_1_MONTH) - priceClose(TRADING_DAYS_6_MONTH )) / priceClose(TRADING_DAYS_6_MONTH);
			var mom3 =  (priceClose(TRADING_DAYS_1_MONTH) - priceClose(TRADING_DAYS_3_MONTH )) / priceClose(TRADING_DAYS_3_MONTH);
			
			var compositeMomentum = (mom12+mom6+mom3)/3.;
			Returns[asset_num] = compositeMomentum;
			asset_num++;
		}
		
		
		//Capital = 100000;		
		//Margin = Capital+WinTotal-LossTotal;
		
		// sort returns lowest to highest
		int* idx = sortIdx(Returns, -asset_num);
		sortData(Returns, -asset_num);
		
		int i, j = 0;
		for(; j < 10; i++)
		{
			asset(Assets[idx[i]]);
			if (priceClose(0) == 0) {
				printf("nPrice is 0 for %s, skipping", Asset);
				continue;
			}

			var size = round(10000.0/priceClose(0));
			printf("nBuying %f %s at %f", size, Asset, priceClose(0));
			enterLong(size);
			j++;
		}
		printf("n--------------------------");