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

[amibroker] Re: Auto-optimization AFL uploaded



PureBytes Links

Trading Reference Links

Hello,

I have read nearly one meter of books and I remember one " the 
ultimate trading guide". it backtests p 216 a simple donchian system 
that is reoptimized on a rolling 2 years basis, the results were 
worst than static parameters and the conclusion was that 
reoptimization does not work...

stephane


 wrote:
> re the bug, you're correct, thanks. I don't specifically remember 
fixing it,
> but it's wrong as you found in v1, but corrected in the unreleased 
v1.1.
> 
> re the possibility that profitability isn't great because 
optimization
> happens too often, you got that you can control how often that gets 
done,
> right? in the framework configuration section, 
equity_lookback_frequency is
> the number of bars between optimizations, with 0 meaning every day 
and -1
> meaning optimize once at the beginning.
> 
> 
> re other reasons why this doesn't make systems profitable, well, 
that's a
> very very very interesting question, one I've thought and posted 
about a
> lot.
> 
> I don't see any huge difference in principle between auto-
optimization and
> backtesting in general. when we say some strategy works well, we 
generally
> mean that someone backtested it at some point in time, with some 
particular
> set of parameters, and it worked well. if another person hears 
about it 25
> years later, and backtests with data going up to that much later 
date, they
> may get very different optimal parameters, or a completely failing 
result
> with any settings. so our evaluation of systems and their 
parameters is
> always dependent on the time frame we chose to examine.
> 
> if that's the case, it seems to me that a robust system should be
> optimizable at any given point in time, and be successful going 
forward with
> those best-choice parameters. re-optimizing every day takes that to 
an
> extreme, but avoids completely arbitrary decisions about when to 
optimize
> and when not to. every week? month? year? every saturday? every 
january 1?
> june 22? what possible justification is there for any of these? to 
put it
> differently, why does ignoring possible changes in market dynamics 
in
> between optimizations improve the performance or reliability of a 
system?
> 
> outside of when you choose to optimize, it fundamentally comes down 
to
> whether past performance predicts future performance or not. if
> auto-optimization fails as a concept, doesn't that say that there's 
a basic
> disconnect between how a system and settings performed in the past 
and how
> it does in the future? if that's true, why do we believe that any 
backtest
> results tell us anything useful at all?
> 
> one possible answer is that raw profitability may not be the best 
predictor
> of future performance, so we need better metrics to judge past 
performance
> than simple equity growth. the framework comes with two rules for 
scoring
> performance during optimization, and you're heartily encouraged to 
edit
> those or add your own.
> 
> 
> if I really believed that observing past performance told us 
nothing about
> the future, I'd have to abandon TA completely and look to 
fundamentals,
> industry news and knowledge, etc for trading strategy. I haven't 
gone that
> far obviously, but I'm at a loss to explain away the argument I've 
just
> given. better performance metrics are the only logical avenue I can 
see out
> of that dead end.
> 
> I don't mean to sound like I think I've got this all figured out, 
quite the
> opposite. I feel like I've disproved my own existence or something, 
proved
> the impossible. so please, somebody, wise me up!
> 
> dave
>   update:
> 
>   I have attached a file with my settings and results by rule. 
(Again, I
> used
>   QQQ daily data for from 1/2/3 to 10/28/3.)
> 
>   I agree with your statement: '...almost no trading rules I've 
tested are
>   very profitable when managed this way, with any framework 
settings I've
>   tried...'
> 
>   So, I wonder what this means? Perhaps the optimization happens too
>   frequently?
> 
>   -john
> 
>   Also I found a possible bug in BuySellStochCCI.  I added the 
second line
>   below:
> 
>   function BuySellStochCCI(dynamic, p1, p2) { // p1 = CCI period
>       period=p1; //added this to Dave's code
>       cc = CCIx(period);
>       cc = StochTransform(cc, period);
>       Buy = Cover = Cross(cc, 50);
>       Sell = Short = Cross(50, cc);
>   }
> 
> 
> 
>   ----- Original Message -----
>   From: john gibb
>   To: amibroker@xxxxxxxxxxxxxxx
>   Sent: Wednesday, October 29, 2003 10:33 AM
>   Subject: Re: [amibroker] Auto-optimization AFL uploaded
> 
> 
>   I assume by 'analysis mode' you mean Scan mode; right?
> 
>   And, yes, the Index Symbols below have no 
Buys/Sells/Shorts/Covers with
> 'my'
>   rule in Scan mode, although they do have volume...
> 
>   Since it seems to be working, I am now wondering what my next 
step should
>   be, given my ultimate objective of a QQQ options system that uses 
EOD
> data.
>   I welcome your inputs on this, but I think I will first take 
advantage of
>   all the rules you have provided and compare, via the sum of 
BackTest
> Profit,
>   their QQQ results with those of my rule. (And I will also record 
Explore
>   results so I can see the optimum parameter values, although I am 
not clear
>   on how to best utilize these results yet.)
> 
>   thanks again
> 
>   -john
>   ----- Original Message -----
>   From: Dave Merrill
>   To: amibroker@xxxxxxxxxxxxxxx
>   Sent: Tuesday, October 28, 2003 7:03 PM
>   Subject: RE: [amibroker] Auto-optimization AFL uploaded
> 
> 
>   glad it's working. it's too bad the no-array limitations on the 
native AB
>   functions make us get a little more techie about this than we'd 
otherwise
>   have to, it's workable.
> 
>   re no rows, near the bottom is the exploration code, including 
the filter
>   statement, which I think defaults to buy or sell or short or 
cover. if
>   that's what you want, then the problem is probably that you're 
not seeing
>   any buys, in analysis mode either, yes? if so, make sure the 
index tickers
>   you're using have volume data (some do some don't in the 
QuotesPlus data I
>   use), or modify the minimum volume requirement in the TRADE ENTRY
>   RESTRICTIONS section.
> 
>   that's actually the sleazy answer. a better one is to look in the
> FRAMEWORK
>   ENGINE section, at 'tweak volume entry requirements for things 
with no
>   volume data', and find this expression:
>       StrLeft(Name(), 1) == "!"
>   with my QuotesPlus data, that's how indexes are flagged, by 
having their
>   ticker names begin with "!". with other providers, it's probably
> different;
>   I think yahoo is "^", for example. change that code, and anything 
with
> that
>   prefix won't be subject to the minimum volume rule in TRADE ENTRY
>   RESTRICTIONS. the unreleased update of the framework has a better 
way of
>   handling this.
> 
>   hope this helps,
> 
>   dave
>   It works!!!! Making my MFI period, p1, a constant, eliminated the
>   error...thanks
> 
>   Then, since sum() appears to take an array for its period, I was 
able to
> get
>   this updated, dynamic-or-not function to run:
> 
>   function BuySellPcntBMFI(dynamic, p1, p2) { // p1 = MFI period, 
p2 = high
>   crossover threshhold
>       price = Close;
>       BA = 20; //Bband MA
>       BD = 2;//Bband Stdev
>       BL = ML = 20;// lower crossover threshhold
>       MP = p1;// MFI period
>       if(dynamic) {
>           MoneyFlow = V * Avg;
>           Change = Avg - Ref( Avg, -1 );
>           PositiveFlow=Sum( IIf( Change > 0, MoneyFlow, 0 ) ,p1 );
>           NegativeFlow=Sum( IIf( Change < 0, MoneyFlow, 0 ) ,p1 );
>           MoneyRatio=PositiveFlow/NegativeFlow;
>           MFIndex=100-(100/(1+MoneyRatio));
>       } else {
>           MFIndex=MFI(MP);
>       }
>       MH = BH = p2;// higher crossover threshhold
>       b= ((price - BBandBot( price, BA, BD )) / (BBandTop( price, 
BA, BD ) -
>   BBandBot(price, BA, BD ))) * 100;
>       Buy = Cover = b > BH AND MFIndex > MH;
>       Sell = Short = b < BL AND MFIndex < ML;
>   }
> 
>   thanks again
> 
>   -john
> 
>   BTW, when I use 1990-to-current EOD data for MSN's $COMPX or 
Yahoo's ^IXIC
>   (both supposedly the NASDAQ composite) as my 'current stock', i 
get a
> single
>   result row for Backtest and NO rows, just headers, for Explore.
> Individual
>   stocks do yield multiple rows.
> 
> 
>   ----- Original Message -----
>   From: Dave Merrill
>   To: amibroker@xxxxxxxxxxxxxxx
>   Sent: Tuesday, October 28, 2003 12:09 PM
>   Subject: RE: [amibroker] Auto-optimization AFL uploaded
> 
> 
>   hi john, I don't have time right now to mess in detail w this, 
but try
>   temporarily replacing p2 with a fixed number and see if the error 
goes
> away.
>   it won't give you correct results, but might verify my suspicion, 
which is
>   that AB's BBand functions can't take arrays for their period. if 
that's
> the
>   case, you'd need to code a replacement in AFL that can, or if 
we're lucky,
>   maybe those functions are part of indicators.dll.
> 
>   I hope that some day soon, we'll get versions of all built in AB
> indicators
>   that are array-capable. many of them already are, and it would be 
great if
>   life was that kind of symetrical, not to mention useful.
> 
>   dave
> 
>   I think i have a 'dynamic=false' situation like your 
BuySellStoch. (I am
>   using p1 as the number of periods for MFI() and assume that this
>   "mfi(periods=14)" syntax in Help means that MFI can take only a
> single-value
>   parameter. And p2 is a single-value crossover threshold for 
Bollinger's
> %b.)
> 
>   FWIW, here is my rule code producing the error:
> 
>   function BuySellPcntBMFI(dynamic, p1, p2) { // p1 = MFI period, 
p2 = high
>   crossover threshhold
>       price = Close;
>       BA = 20; //Bband MA
>       BD = 2;//Bband Stdev
>       BL = ML = 20;// lower crossover threshhold
>       MP = p1;// MFI period
>       MH = BH = p2;// higher crossover threshhold
>       //b is Bollinger's %b
>       b = ((price - BBandBot( price, BA, BD )) / (BBandTop( price, 
BA,
> BD ) -
>   BBandBot(price, BA, BD ))) * 100;
>       Buy = Cover = b > BH AND MFI(MP) > MH;
>       Sell = Short = b < BL AND MFI(MP) < ML;
>   }
> 
>   TIA,
> 
>   -john
> 
>   ----- Original Message -----
>   From: Dave Merrill
>   To: amibroker@xxxxxxxxxxxxxxx
>   Sent: Tuesday, October 28, 2003 8:03 AM
>   Subject: RE: [amibroker] Auto-optimization AFL
> 
> 
>   thanks for the compliments, glad it's kind of sane in there (:-).
> 
>   just FYI, there's a new version of this that I haven't posted 
yet. among
>   other changes, it handles up to 3 optimization parameters, and 
allows each
>   rule to set the optimization parameter ranges independently. it 
also moves
>   the docs into a separate file, so the code file is smaller and 
easier to
>   deal with. I'll get that up as soon as I can finish it off.
> 
>   no, you don't have to set dynamic yourself, and shouldn't. did 
you read
> the
>   comments about it? I bet it's not dynamic itself that your rule 
is getting
>   hung up on, it's the optimization parameters being arrays when 
dynamic is
>   true.
> 
>   here's the section about this from the newer version, expanded a 
bit from
>   the original; not sure if the example BuySell rules it mentions 
are
> exactly
>   the same:
> 
>   --------------
>   during optimization, the active rule is called multiple times, 
once with
>   each combination of p1, p2 and p3 being tested. at this time, p1, 
p2 and
> p3
>   are simple numeric values, not arrays. once optimal settings have 
been
>   determined for every bar, the rule is called once more, to 
generate actual
>   trading signals. this time, p1, p2 and p3 are arrays, each bar 
dynamically
>   containing the optimal p1, p2 and p3 value for that bar.
> 
>   whether they're simple values or arrays matters because not all AB
> functions
>   can accept arrays as inputs. for example, MA, TEMA, DEMA, WMA and 
AMA can
>   use an array as their period, but EMA and MACD can't. it's usually
> possible
>   to code an equivalent in AFL that can, like the included EMAx 
function is
> a
>   replacement for EMA. an AFL replacement may be significantly 
slower
> though,
>   if it has to do a lot of work, since rules are called many times 
during
>   optimization. you could also use a DLL, like indicators.dll from 
the 3rd
>   party section of the AB site, but I didn't want this code to 
depend on
>   outside tools.
> 
>   if this is an issue for a particular rule, include both slower
> array-capable
>   code for use in the final signal-generation phase, and faster,
>   non-array-capable code for use during the many optimization 
tries. use the
>   'dynamic' parameter to know which to call; see BuySellStoch, 
below, for an
>   example. you can also write a custom function with both versions, 
and pass
>   dynamic into it; see BuySellCCI and CCIx for an example.
>   --------------
> 
>   hth,
> 
>   dave
>   Hi Dave,
> 
>   I started working with it...very nice, structured, work...this 
will help
>   folks learn AFL as well as general programming design, I believe..
> 
>   so far, i am having a bit of trouble with the 'dynamic' True/False
> parameter
>   being fed to one of my indicators---but i suspect this is my 
problem not
>   yours:
> 
>   BuySellRule(True, best_p1, best_p2);
>   -----------------------------------^
> 
>   Bad args.
>   0-th argument of function call has invalid (or unsupported) type
> 
>   I don't have to specifically set 'dynamic'; do I?
> 
>   thanks
> 
>   -john
>   ----- Original Message -----
>   From: Dave Merrill
>   To: amibroker@xxxxxxxxxxxxxxx
>   Sent: Thursday, October 23, 2003 6:32 PM
>   Subject: RE: [amibroker] Auto-optimization AFL uploaded
> 
> 
>   thanks, appreciate it (:-).
> 
>   so, did you figure out how we can all be millionaires by morning 
with it
>   yet? or at least learn something about something?
> 
>   you probably noticed this, but the way it comes set up, it's not 
using
>   equity feedback to optimize with, but net bars on the right side 
of the
>   market. my initial impression after I built that was that it 
worked better
>   than equity, but since then, I've concluded that, guess what, it 
depends.
> so
>   anyway, try the other scoring algorithm too, if you haven't 
already.
> 
>   keep me posted (:-).
> 
>   anyone else playing with this thing?
> 
>   dave
>   I've downloaded it and run it about a dozen times.  What you've 
done is
> very
>   impressive.
> 
>   Thanks,
>   Howard
> 
>   -----Original Message-----
>   From: Dave Merrill [mailto:dmerrill@x...]
>   Sent: Wednesday, October 22, 2003 1:11 PM
>   To: amibroker@xxxxxxxxxxxxxxx
>   Subject: RE: [amibroker] Auto-optimization AFL uploaded
> 
>   forgot to say it howard, but I'm very interested in what you 
think about
> it,
>   and any results you get from fiddling with it.
> 
>   dave
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at:
>   http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>   Yahoo! Groups Sponsor
>   ADVERTISEMENT
> 
> 
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at:
>   http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
>         Yahoo! Groups Sponsor
> 
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs from home.
Over 14,500 titles. Free Shipping
& No Late Fees. Try Netflix for FREE!
http://us.click.yahoo.com/ybSovB/hP.FAA/3jkFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/