danatrader thanks again for your reply

I looked at "Petra on Programming: Four Dimensions of Strength" and I got the response I looked for.

Here is the updated code:
Code
function run()
{
	set(PARAMETERS+LOGFILE+PLOTNOW);
//	set(LOGFILE+PLOTNOW);
	BarPeriod    = 1440;
	LookBack     = 120;
	Verbose      = 0;
	var Weights[6];
	string Stocks[6];
        Capital = 10000;
//	NumWFOCycles = 5;
	
	
	
	while(asset(loop(""MDY", "TLT", "EEM", "ILF", "EPP", "FEZ"")))
	{
		Returns[Itor1] = RET(optimize(60,20,120,20));
		Stocks[Itor1]  = Loop1;
	}
	
	
	if (month(0) != month(1)) { // once a month do
		int i;
		distribute(Weights,Returns,6,1,0);

		for(i=0;i<6;i++) {

			asset(Stocks[i]);
			int NewShares = Weights[i]*Balance/priceClose(0) - LotsPool;

			if(NewShares > 0)
				enterLong(NewShares);
			else if(NewShares < 0)
			        exitLong("",-NewShares);
		}
	}

}




This code optimizes each asset separately as expected