Hi - OK here's my take on it...you want to buy when the short MA crosses above the long MA, so to describe it correctly, you should really say something like
Buy = Cross( shortMA, longMA ); or Buy = shortMA > longMA and ref( shortMA, -1 ) < ref( longMA, -1 ); When you just say Buy = shortMA > longMA; AB will mark the Buy array with a 1, not just on crossover bars, but on all bars where shortMA is > longMA. It is doing exactly what you told it, but you have not told it what you really want. However, AB's backtester automatically removes redundant signals, so in a backtest you may end up getting the correct results anyway, whereas in an exploration you would not. Sorry, I can't comment on the AFL Wizard, I have never used it. Re your optimization results, did you compare number of trades? What first comes to mind is that 133 is a fairly long average and perhaps you only had the same 1 or so crosses/trades in all cases? You could comment out the Opt statements and run a few tests plugging in individual numbers, then look at the detailed reports to verify the trades. Also, you might just try giving them different names inside the Opt() function, I don't know offhand if naming them both the same could possibly have any effect of not. Good luck! Steve ----- Original Message ----- From: "longarm61" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Sunday, August 19, 2007 11:13 PM Subject: [amibroker] Re: Optimization Help > Hey, Steve, thanks for the reply. That's interesting because I used > the AFL Wizard for my buy and sell code. Wonder why it would give me > code that generates a buy for every bar that remains above the MA? > It's also interesting that for a 1-month backtest using 5-minute > bars, my original code yielded only 1 more trade (line) than your > code did. > > But the thing I'd really like help understanding is the > Optimization. I tried it using your code and I'm still confused by > the results. For example, it shows: > > NET % PROFIT MA MA > ------------ ---- ---- > 3.28 133 5 > 3.28 133 15 > 3.28 133 8 > 3.28 133 9 > > As you can see, it shows the same net % profit for every result with > a MA of 133, even though the MAs in the second column are all > different. In fact, ALL the numbers in all the columns are > indentical for the MA-133. Why would that be? Doesn't the first MA > above represent MA1 and the second MA represent MA2? > > Either I'm still doing something wrong or I'm misunderstanding > something (very possible!), since obviously trades with different MAs > for sells aren't going to have the exact same results, even if buys > use the same MA. > > Looking for enlightenment. Thanks. > > > > > > > > > --- In [email protected], "Steve Dugas" <[EMAIL PROTECTED]> wrote: >> >> Hi, your code gives buy sig not just on crossover but also on every > bar >> where MA3 remains above the MA it just crossed. Similar result for > sell >> sigs. Try it this way... >> >> Buy = Cross( MA( Close , 3 ), MA( Close , MA1 ) ); >> Sell = Cross( MA( Close , MA2 ), MA( Close , 3 ) ); >> >> Steve >> >> ----- Original Message ----- >> From: "longarm61" <[EMAIL PROTECTED]> >> To: <[email protected]> >> Sent: Sunday, August 19, 2007 6:09 PM >> Subject: [amibroker] Optimization Help >> >> >> > Hello, complete AFL newbie here. This should be a simple one. > If I >> > have a system whereby a 3-bar MA crosses another MA to buy, and a > 3- >> > bar MA crosses a different MA to sell, how would I code the >> > optimization to find the most profitable COMBINATION of MAs for > the >> > buy and sell? >> > >> > Here's how I attempted to do it--I know it's wrong, as it crunched >> > numbers for about 2 hours but then gave me results that made no > sense: >> > >> > >> > MA1 = Optimize ( "MA", 50, 5, 200, 1 ); >> > MA2 = Optimize ( "MA", 50, 5, 200, 1 ); >> > >> > Buy = MA( Close , 3 ) > MA( Close , MA1 ); >> > >> > Sell = MA( Close , 3 ) < MA( Close , MA2 ); >> > >> > Short = 0; >> > >> > Cover = 0; >> > >> > >> > Thanks in advance for your patience and help. >> > >> > >> > >> > Please note that this group is for discussion between users only. >> > >> > To get support from AmiBroker please send an e-mail directly to >> > SUPPORT {at} amibroker.com >> > >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: >> > http://www.amibroker.com/devlog/ >> > >> > For other support material please check also: >> > http://www.amibroker.com/support.html >> > >> > Yahoo! Groups Links >> > >> > >> > >> > >> > > > > > Please note that this group is for discussion between users only. > > To get support from AmiBroker please send an e-mail directly to > SUPPORT {at} amibroker.com > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > http://www.amibroker.com/devlog/ > > For other support material please check also: > http://www.amibroker.com/support.html > > Yahoo! Groups Links > > > >
