Peter,

I think you are over complicating, there is nothing I see that needs a function.

Code:
function run()
{
	Stop = 1*ATR(100);
	TakeProfit = 50*PIP;
	Trail = 4*ATR(100);
	
	vars Price = series(priceClose());
	vars rule01Bias = series(SMA(Price,100));
	
	if (priceClose(1) > rule01Bias[1]
	 and priceHigh(1) < priceHigh(2)
	  and priceLow(1) < priceLow(2))
		enterLong(1,(priceHigh(1) + 3*PIP));
	if (priceClose(1) < rule01Bias[1]
	 and	priceHigh(1) > priceHigh(2)
	 	and priceLow(1) > priceLow(2))
	 	enterShort(1,(priceLow(1) - 3*PIP));
}



Note that index 0 is the last bar, in this script you are using the 2nd & 3rd most recent bars. Is that intentional?

Also the trail distance at 4*ATR seems a little high considering the stop is only 1*ATR and the TP is 50 pips.

Last edited by swingtraderkk; 03/14/14 15:27.