Originally Posted By: jcl

Code:
function run()
{
	StartDate = 20021021;
	EndDate = 20080704;
	BarPeriod = 30;
	LookBack = 30;
	set(TICKS|PLOTNOW);
	PlotWidth = 800;

	asset("GBP/USD");

// no commissions...	
	Spread = 0;
	Slippage = 0;
	RollLong = RollShort = 0; 
	
	vars Price = series(priceClose()),
		Fast = series(SMA(Price,3)),
		Slow = series(SMA(Price,30));
	
	static var BuyLimit,SellLimit,BuyStop,SellStop;
	
	if(crossOver(Fast,Slow)) {
		BuyStop = priceHigh() + 1*PIP;
		BuyLimit = priceHigh() + 5*PIP;
	}
	if(crossUnder(Fast,Slow)) {
		SellStop = priceLow() - 1*PIP;
		SellLimit = priceLow() - 5*PIP;
	}
		
	if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit)
		enterLong(1,BuyStop);
	if(!NumOpenShort && Fast[0] < Slow[0] && Price[0] > SellLimit)
		enterShort(1,SellStop);
}




Hi jcl. I have 2 questions for you. First question. The pending order 'enterLong(1,BuyStop)', is automatically cancelled after the end of the first bar if not entered. Is it correct?
Second question.
In the istruction 'if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit)' the part 'Fast[0] > Slow[0]' isn't redundant? (because the condition is already verified by the crossover function). And why did you use 'Price[0] < BuyLimit' if the BuyStop is smaller than BuyLimit?
Thanks a lot!