The script is working! Your answer helped me, thank you.

Another thing is, that I was getting "Crash in the script error", only once, at the first day after the lookback period.

After debugging, I found that:
- the error is there only when I use SPY data (from IVolatility)
- the error is not there when I use artificial historical data generated by financial-hacker script
- the error is caused by Contracts->fUnl
- the error is there when the code looks like this:
Code:
while (assetName = loop(Assets)) {
		if (assetName == "SPY") contractUpdate(assetName,1,CALL|PUT);
		else if (assetName == "YHOO") contractUpdate(assetName,2,CALL|PUT);
		asset(assetName);
		var CurrentPrice = ifelse(is(TRADEMODE),priceClose(),Contracts->fUnl);
......


when I select the asset before contractUpdate, there is no Crash in the script. My code without errors is:
Code:
while (assetName = loop(Assets)) {
		asset(assetName);
		if (assetName == "SPY") contractUpdate(assetName,1,CALL|PUT);
		else if (assetName == "YHOO") contractUpdate(assetName,2,CALL|PUT);
		var CurrentPrice = ifelse(is(TRADEMODE),priceClose(),Contracts->fUnl);