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

RE: [amibroker] Auto-optimization AFL uploaded



PureBytes Links

Trading Reference Links




<SPAN 
class=587362920-29102003>comments below...
<SPAN 
class=587362920-29102003> 
<BLOCKQUOTE 
>
  I assume by 'analysis mode' you mean Scan 
  mode; right?<FONT face="Courier New" 
  color=#0000ff> 
<FONT 
face=Arial>I meant backtest or 
portfolio backtest. I rarely use scan 
mode.
<FONT 
face=Arial><SPAN 
class=587362920-29102003> 
<BLOCKQUOTE 
>
  <SPAN 
  class=587362920-29102003> <FONT 
  size=2>And, yes, the Index Symbols below have no Buys/Sells/Shorts/Covers with 
  'my' rule in Scan mode, although they do have volume...<SPAN 
  class=587362920-29102003><FONT face="Courier New" 
  color=#0000ff> 
<SPAN 
class=587362920-29102003>try commenting out the whole trade entry 
restrictions section. if you still get no trades, it could mean that no 
combination of parameter values was profitable, over any part of the time period 
tested. don't think I've ever seen that, but I can't think of any other reason 
why it wouldn't trade.
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003>if you want to, email me your code and I'll poke around 
a bit when I get a chance.
<SPAN 
class=587362920-29102003> 
<BLOCKQUOTE 
>
  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.)<FONT 
  face="Courier New" 
color=#0000ff> 
<SPAN 
class=587362920-29102003>hmmm. don't think I can offer much on qqq 
options.
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003>"working" is a relative thing (;-). I 
understood you to be saying that you still weren't seeing any trades, right? 
have you tried this system w completely static parameters outside the 
auto-optimize framework? do you get any trades then? if so, try setting the 
auto-optimization paremters up with the start and end values the same, so 
only that one value is tried, and see if you get trades 
then.
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003>re making use of the optimum parameter values you see 
when exploring: plain old optimization, where one range of data is examined to 
find one set of optimum parameter values, you might as well do with AB's built 
in tools. what auto-optimization does that that can't is vary parameters over 
time in response to changing market conditions. if you have a trading strategy 
and an equity scoring method that work well together (big if, in my 
experience), the resulting system should adjust itself towards profitability 
dynamically over time. 
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003>the only practical way I know of to trade that total 
system is to backtest or explore it within the auto-optimization framework, and 
trade the resulting signals. recording optimum parameter values at various 
points in time is kind of useless, and more work besides. I do look at the 
optimum values it generates sometimes, out of curiousity, and to think 
about how I could improve the system, maybe by widening or narrowing the 
optimization ranges, adding stops, or some other way. for instance, check if a 
parameter is stuck way at one end of the allowed range, or isn't changing 
at all, or values in certain ranges are never profitable, whatever patterns 
there are that might be useful to know.
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003> 
<SPAN 
class=587362920-29102003>dave
<SPAN 
class=587362920-29102003> 
<BLOCKQUOTE 
>
  thanks again
   
  -john
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    Dave Merrill 
    
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Sent: Tuesday, October 28, 2003 7:03 
    PM
    Subject: RE: [amibroker] 
    Auto-optimization AFL uploaded
    
    <SPAN 
    class=155574802-29102003>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.
    <SPAN 
    class=155574802-29102003> 
    <SPAN 
    class=155574802-29102003>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. 
    <SPAN 
    class=155574802-29102003> 
    <SPAN 
    class=155574802-29102003>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:
    <SPAN 
    class=155574802-29102003>    StrLeft(Name(), 1) == 
    "!"
    <SPAN 
    class=155574802-29102003>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.
    <SPAN 
    class=155574802-29102003> 
    <SPAN 
    class=155574802-29102003>hope this helps,
    <SPAN 
    class=155574802-29102003> 
    <SPAN 
    class=155574802-29102003>dave
    <BLOCKQUOTE 
    >It 
      works!!!! Making my MFI period, p1, a constant, eliminated 
      theerror...thanksThen, since sum() appears to take an array 
      for its period, I was able to getthis updated, dynamic-or-not function 
      to run:function BuySellPcntBMFI(dynamic, p1, p2) { // p1 = MFI 
      period, p2 = highcrossover 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-johnBTW, 
      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 singleresult row for Backtest and NO rows, just headers, for 
      Explore.  Individualstocks do yield multiple 
      rows.----- Original Message ----- From: Dave 
      MerrillTo: amibroker@xxxxxxxxxxxxxxxSent: Tuesday, October 28, 
      2003 12:09 PMSubject: RE: [amibroker] Auto-optimization AFL 
      uploadedhi john, I don't have time right now to mess in detail 
      w this, but trytemporarily 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 isthat AB's BBand functions can't take 
      arrays for their period. if that's thecase, 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 indicatorsthat are array-capable. many of 
      them already are, and it would be great iflife was that kind of 
      symetrical, not to mention useful.daveI think i have a 
      'dynamic=false' situation like your BuySellStoch. (I amusing 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-valueparameter. 
      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 = highcrossover 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 MerrillTo: amibroker@xxxxxxxxxxxxxxxSent: Tuesday, 
      October 28, 2003 8:03 AMSubject: RE: [amibroker] Auto-optimization 
      AFLthanks 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. amongother changes, it handles up to 3 optimization parameters, 
      and allows eachrule to set the optimization parameter ranges 
      independently. it also movesthe docs into a separate file, so the code 
      file is smaller and easier todeal 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 thecomments about it? I bet it's not dynamic 
      itself that your rule is gettinghung up on, it's the optimization 
      parameters being arrays when dynamic istrue.here's the section 
      about this from the newer version, expanded a bit fromthe original; 
      not sure if the example BuySell rules it mentions are exactlythe 
      same:--------------during optimization, the active rule is 
      called multiple times, once witheach combination of p1, p2 and p3 
      being tested. at this time, p1, p2 and p3are simple numeric values, 
      not arrays. once optimal settings have beendetermined for every bar, 
      the rule is called once more, to generate actualtrading signals. this 
      time, p1, p2 and p3 are arrays, each bar dynamicallycontaining the 
      optimal p1, p2 and p3 value for that bar.whether they're simple 
      values or arrays matters because not all AB functionscan accept arrays 
      as inputs. for example, MA, TEMA, DEMA, WMA and AMA canuse an array as 
      their period, but EMA and MACD can't. it's usually possibleto code an 
      equivalent in AFL that can, like the included EMAx function is 
      areplacement 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 duringoptimization. you could also use a DLL, like 
      indicators.dll from the 3rdparty section of the AB site, but I didn't 
      want this code to depend onoutside tools.if this is an issue 
      for a particular rule, include both slower array-capablecode 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 
      anexample. you can also write a custom function with both versions, 
      and passdynamic into it; see BuySellCCI and CCIx for an 
      example.--------------hth,daveHi Dave,I 
      started working with it...very nice, structured, work...this will 
      helpfolks learn AFL as well as general programming design, I 
      believe..so far, i am having a bit of trouble with the 'dynamic' 
      True/False parameterbeing fed to one of my indicators---but i suspect 
      this is my problem notyours:BuySellRule(True, best_p1, 
      best_p2);-----------------------------------^Bad args.0-th 
      argument of function call has invalid (or unsupported) typeI don't 
      have to specifically set 'dynamic'; do 
      I?thanks-john----- Original Message ----- From: 
      Dave MerrillTo: amibroker@xxxxxxxxxxxxxxxSent: Thursday, October 
      23, 2003 6:32 PMSubject: RE: [amibroker] Auto-optimization AFL 
      uploadedthanks, appreciate it (:-).so, did you figure 
      out how we can all be millionaires by morning with ityet? or at least 
      learn something about something?you probably noticed this, but the 
      way it comes set up, it's not usingequity feedback to optimize with, 
      but net bars on the right side of themarket. my initial impression 
      after I built that was that it worked betterthan equity, but since 
      then, I've concluded that, guess what, it depends. soanyway, try the 
      other scoring algorithm too, if you haven't already.keep me posted 
      (:-).anyone else playing with this thing?daveI've 
      downloaded it and run it about a dozen times.  What you've done is 
      veryimpressive.Thanks,Howard-----Original 
      Message-----From: Dave Merrill [mailto:dmerrill@xxxxxxx]Sent: 
      Wednesday, October 22, 2003 1:11 PMTo: 
      amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker] Auto-optimization 
      AFL uploadedforgot to say it howard, but I'm very interested in 
      what you think about it,and any results you get from fiddling with 
      it.daveSend BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
    Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT











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 the Yahoo! Terms of Service.