Hi all,

Had a go at fixing this according to the rules published.

Not profitable as far as I can see since fixed, was more profitable in its broken state?????

BTW I can see no logic for the ATR rule, except perhaps an indication of momentum in favour of the trade, but if so why does the rule state that the atr should be under its 21d ma for shorts? surely it should be > 21d ma of atr for shorts also?

Haven't time to back test variants, but would appreciate if anyone can spot my errors as I'm a noob too.

Code:
function run()
{
set(PARAMETERS+FACTORS+TESTNOW);
BarPeriod = 5;
StartDate = 2002;
//NumYears = 7;
//NumWFOCycles = 10;
LookBack = 100;

vars Close = series(priceClose());
vars High = series(priceHigh());
vars Low = series(priceLow());
vars PLUSDI14 = series(PlusDI(14));
vars MINUSDI14 = series(MinusDI(14));
vars ADX14 = series(ADX(14));
vars ATR11 = series(ATR(11));
vars SMAATR11 = series(SMA(ATR11,21));

int profit = optimize(20,5,200,5);

if(lhour(UTC) >= 7 and lhour(UTC) <= 21)
	{
	if((ADX14[0] > 25) and (ATR11[0] > SMAATR11[0]) and crossOver(PLUSDI14,MINUSDI14))
		{
			Stop = (max(2+((Close[0]-Low[0])/PIP),15))*PIP;
			TakeProfit = profit*PIP;
			enterLong();			
		}
	else
		{
			if((ADX14[0] > 25) and (ATR11[0] > SMAATR11[0]) and (crossOver(MINUSDI14,PLUSDI14)))
			{
			Stop = (max(2+((High[0]-Close[0])/PIP),15))*PIP;
			TakeProfit = profit*PIP;
			enterShort();
			}
		}
	}
plot("ADX14",ADX14[0],NEW,0x0000CC);
plot("ADX25",25,0,SILVER);
plot("ATR11",ATR11[0],NEW,BLUE);
plot("SMAATR11",SMAATR11[0],0,SILVER);

}


Last edited by swingtraderkk; 07/19/13 17:10.