[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple MA Crossing System



PureBytes Links

Trading Reference Links

Hello Mike,

I am also a newbie but I did have a few comments & questions.

In your AA setting, are you buying on open or open+1 ? If you have 
it set to on open, aren't you then buying before the condition 
actually occurs ? Shouldn't you be buying on open+1 ? Or couldn't 
you just remove the ref (-1) part, keep just the cross condition and 
in the settings put buy+1 as the buy price ?

Also, I tested out your system (maShort=15 & maShort=30) on all the 
stocks on the Dow 30 from 1990-today. It returned a 16.54 % 
annualized return while buy&hold returned 15.97% annualized.

However, when I start testing it on a shorter timeframe (i.e. less 
than 4 years back), the performance drops into the negatives.

Also, why are you using "> 0" and "< 0" in your buy/sell 
conditions ? Why don't you just use the cross condition ? 

Regards,
HB


--- In amibroker@xxxx, "mike_stoecker" <wwkayak@xxxx> wrote:
> Folks,
> 
> I'm a new user - lurking on this group for a handful of months - 
just 
> now beginning to try to actually use AB.
> 
> I tried to code a simple moving average system which apparently is 
a 
> lousy system (huge negative return on backtesting with the limited 
> historical data I used (QQQ).
> 
> I'm hoping the more accomplished AB programmers/users on this 
group 
> can examine my afl code below and tell me if I'm missing "pieces" 
in 
> the system or recommend ways to improve the code (not necessarily 
the 
> system).
> 
> Again, I "tested" this on QQQ in the AA tool. Probably did messed 
> that up too.
> 
> I promise I'll begin reading the manual (beyond looking up syntax 
for 
> the Cross function, etc).
> 
> Thanks, much.
> 
> Michael
> 
> 
> Anyway, here is the code:
> 
> /* MA Cross-Over System */
> 
> 
> //maShort = 9;
> maShort = Optimize("ShortMA Term",9,5,15,1);
> 
> //maLong = 36;
> maLong = Optimize("LongMA Term",36,26,44,2);
> 
> // Buy at open if the previous day's short-term MA crosses above 
the 
> long-term MA
> 
> Buy = Ref(Cross(MA(Close,maShort),MA(Close,maLong)),-1) > 0;
> 
> // Exit with a profit or loss at the open if the previous day's 
short-
> term MA crosses below the long-term MA
> 
> Sell = Ref(Cross(MA(Close,maShort),MA(Close,maLong)),-1) < 0;
> 
> // Exit with a loss if the stock goes against the position by more 
> than 4 times the 10-day ATR
> 
> ApplyStop(0,2,4*ATR(10),1);