Thanks jcl. I've been to the manual many times. But that doesn't mean I understand it all! laugh

First, shouldn't the error/result be the same no matter where BarPeriod is set?

As for the example code, this:
Code:
function run()
{
	set(PARAMETERS);
	BarPeriod = optimize(240,60,1440,60);
	Stop =	10 * PIP;
	Trail =	10 * PIP;
	enterLong();
}



gives identical results for all optimize parameters I've tried so far.

This:

Code:
function run()
{
	set(PARAMETERS);
	if(is(INITRUN)) BarPeriod = optimize(240,60,1440,60);
	Stop =	10 * PIP;
	Trail =	10 * PIP;
	enterLong();
}



gives the Error 040.