Alessio, jcl,

I decided to sketch this out to help my learning. Posted here for anyone reading back. This now charts the price movements and, I think, shows that it doesn't trade because the conditions are never met:

Code:
function run ()
{
	//no trade costs...	
	BarPeriod = 5;
	Spread = 0;
	Slippage = 0;
	RollLong = RollShort = 0; 

	vars Price = series(priceClose()); 
	var HighC = MaxVal(Price,6);
	var LowC = MinVal(Price,6);
	var PriceRange = (priceHigh()-priceLow());
	var BuyStop = priceClose() + 1*PIP;
	var SellStop = priceLow() - 1*PIP;
	TakeProfit = 150*PIP;
	Stop = 200*PIP;	

	if (Price[0] > (HighC + PriceRange))
		enterLong(1,BuyStop, TakeProfit, Stop); 

	if (Price[0] < (LowC - PriceRange))
		enterShort(1,SellStop);
		
	plot("HighC", HighC + PriceRange, MAIN, GREEN);
	plot("LowC", LowC - PriceRange, MAIN, RED);
	set(PLOTNOW+PLOTLONG);
		
}



Changing the conditions for a trade confirms this:

Code:
var priceTrigger = PriceRange / 2;

	if (Price[0] >= (HighC + priceTrigger))
		enterLong(1,BuyStop, TakeProfit, Stop); 

	if (Price[0] <= (LowC - priceTrigger))
		enterShort(1,SellStop);



That changes the trigger condition to a smaller distance and this causes the strategy to trade infrequently at a loss (in my tests).

Last edited by Toronado; 09/14/15 17:28.