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

RE: [amibroker] Re: BarsSince(Buy) -- One idea



PureBytes Links

Trading Reference Links

Why don't you just PLOT the arrays, each line in your chart reveals exactly
the same information but in a much more intuitive and visual way. When you
are looking at a chart you ARE looking at ARRAYS of numbers, you can read
the value of the array in the right labels. You can also turn on Price Data
Tooltips and read the value for each line (ARRAY!) in the tooltip window. Or
you can display the values in the Title of the chart.

Charting intermediate results (ARRAYS) is a powerful debugging tool and also
will help you understand how indicators work.

herman
  -----Original Message-----
  From: danielwardadams [mailto:danielwardadams@xxxxxxxxx]
  Sent: Sunday, November 14, 2004 11:54 PM
  To: amibroker@xxxxxxxxxxxxxxx
  Subject: [amibroker] Re: BarsSince(Buy) -- One idea



  Tomasz,
  One idea I had that might make understanding array processing easier
  would be to be able to (optionally) display the array data in a
  spreadsheet-like row and column format in a separate window (in real-
  time). It would also make it obvious which data is in arrays
  versus simple variables. Although there are ways to accomplish the
  same thing (using lots of print statements or title variables which I
  usually do when I'm stuck on a problem), it would be nice to have
  a "debugging pane/window" that displayed some or all this data.

  The following won't be formatted right but is from the users guide.
  If this appeared in a separate pane/window linked to a graph, I think
  it could help a lot.

    Bar          1    2    3     4    5    6     7    8    9   10
  1 High       1,24 1,27 1,25  1,29 1,25 1,29  1,35 1,35 1,37 1,29
  2 Low        1,20 1,21 1,19  1,20 1,21 1,24  1,30 1,28 1,31 1,27
  3 High+Low   2,44 2,48 2,44  2,49 2,46 2,53  2,65 2,63 2,68 2,46
  4 MyVariable 1,22 1,24 1,22 1,245 1,23 1,265 1,325 1,315 1,34 1,23

  Fig 2. AFL steps when processing ( High + Low ) /2

  An easy implementation of it would be to display all active array
  data in a popup window as you move the cursor (selection bar) across
  a chart.

  If you like the idea (or some variation thereof), I'm sure you could
  think of a user friendly way to present the data.

  Dan


  --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
  wrote:
  > Dan,
  >
  > You are right I am too close to this to see things the way others
  do.
  > Partially the problem is often caused by so many ways available
  > to achieve particular goal that most users may find it difficult
  > to find "optimum" one.
  > Partially it is because of relatively small amount of examples
  > found in the guide. I think that increasing number of examples
  > will help.
  > Therefore I have one request to the users:
  > since I am too close to and may come up with too complex or
  > too simplistic examples, I am keen to listen in which areas
  > you are most blocked on and what systems/techniques are difficult
  > to you. Once we complete the list of things being considered
  > as problematic by majority of users I will be able to prepare
  > example codes with explanations that will address your actual
  problems.
  >
  > Best regards,
  > Tomasz Janeczko
  > amibroker.com
  > ----- Original Message -----
  > From: "danielwardadams" <danielwardadams@xxxx>
  > To: <amibroker@xxxxxxxxxxxxxxx>
  > Sent: Saturday, November 13, 2004 3:05 AM
  > Subject: [amibroker] Re: BarsSince(Buy)
  >
  >
  > >
  > >
  > > I hate to jump in the middle of this but in Owen's defense I
  think
  > > there is something about Amibroker that is extremely hard to
  grasp.
  > > I have 35 years experience writing software, 15-20 years
  experience
  > > doing fairly complex spreadsheet applications, and I've read the
  > > (well written) portion of the user's guide on array processing
  > > several times. Yet I'm constantly finding problems in my results -
  -
  > > frequently due to BarSince problems.
  > >
  > > When I find the problems, in retrospect they almost always seems
  > > obvious and I wonder how I could have been do dumb. So I fix them
  and
  > > then -- either right away or a few days later -- I find that I've
  > > introduced one or more other problems (frequently also due to
  > > BarSince).
  > >
  > > Then I look at something like Tomasz's BarSince looping code and
  > > it seems so obvious I wonder how I could have been so dumb.
  > >
  > > I think Tomasz is much too close to it to realize AFL is hard to
  get
  > > your mind around. If you are intimately familiar with the
  processing
  > > underlying every type of statment, I'm sure everything seems easy
  and
  > > obvious.
  > >
  > > Maybe my problem was not biting the bullet and learning how to
  use
  > > loops in the first place. Yet I think I remember reading in the
  > > user's guide that you could accomplish everything with or without
  > > loops and for some reason I thought writing without them was the
  > > newer/better/preferred way to work with AB.
  > >
  > > I also understand Tomasz's reluctance to insert things into the
  > > language which he perceives as compromizing the elegant simplicty
  and
  > > power of AB.
  > >
  > > I don't know what the answer is. There are probably ways to ease
  the
  > > AB learning curve but I won't pretend to know what they are.
  > >
  > > Dan
  > >
  > >
  > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko"
  <amibroker@xxxx>
  > > wrote:
  > >> Hello,
  > >>
  > >> What you wrote is COMPLETELY WRONG.
  > >> You simply completely lack the understanding how BarsSince works,
  > >> how MS works and how AB works.
  > >>
  > >> FYI: Metastock BarsSince works the same as AFLs.
  > >> You simply are misguided by MS formulas using infamous "PREV"
  > > statement
  > >> that is basically the worst idea Equis programmers came up with.
  > >>
  > >> Please READ http://www.amibroker.com/guide/h_understandafl.html
  > >>
  > >> Read it twice, three times or four, five or ten times if
  necessary.
  > >>
  > >> Your problem is that you want to use "PREVIOUS" bar value.
  > >> There are many ways to achive this goal but most general
  > >> is TO USE LOOPING.
  > >> =============
  > >>
  > >> Simple and straightforward AND *FAST* (compared to horrible
  > > MS "Prev")
  > >>
  > >> See sample code that demonstrates it (posted tens of times
  already)
  > >> and also available in
  http://www.amibroker.com/guide/whatsnew.html
  > >> document (at the very end):
  > >>
  > >> /* a sample low-level implementation of Profit-target stop in
  AFL:
  > > */
  > >> Buy = Cross( MACD(), Signal() );
  > >>
  > >> priceatbuy=0;
  > >>
  > >> for( i = 0; i < BarCount; i++ )
  > >> {
  > >>      if( priceatbuy == 0 && Buy[ i ] )
  > >>      priceatbuy = BuyPrice[ i ];
  > >>
  > >>      if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
  > >>      {
  > >>        Sell[ i ] = 1;
  > >>        SellPrice[ i ] = 1.1 * priceatbuy;
  > >>        priceatbuy = 0;
  > >>      }
  > >>      else
  > >>        Sell[ i ] = 0;
  > >> }
  > >>
  > >>
  > >> Best regards,
  > >> Tomasz Janeczko
  > >> amibroker.com
  > >> ----- Original Message -----
  > >> From: "Owen Davies" <owen5819@xxxx>
  > >> To: <amibroker@xxxxxxxxxxxxxxx>
  > >> Sent: Friday, November 12, 2004 2:50 PM
  > >> Subject: Re: [amibroker] BarsSince(Buy)
  > >>
  > >>
  > >> >
  > >> > Tomasz Janeczko wrote:
  > >> >
  > >> >>You can use ExRemSpan instead: (etc.)
  > >> >>
  > >> >
  > >> > I could again go over why this doesn't work?
  > >> >
  > >> > Please trace through the logic of what happens when ExRemSpan
  > > lands you
  > >> > on another day when the Buy conditions are true.
  > >> >
  > >> > For example--the example I used maybe two weeks ago--take the
  > > classic
  > >> > Larry Williams system with a volatility-breakout entrance and
  his
  > >> > "bailout" exit:  Enter when today's High is higher than the
  Open
  > > plus
  > >> > (some fraction of) yesterday's range.  To get out, wait one
  bar,
  > > to give
  > >> > the price time to move, and Sell on the first profitable
  Open.
  > > Use a
  > >> > stop-loss to escape the losers.  So:
  > >> >
  > >> > Buy=H > O + Ref(H - L,-1);
  > >> > BuyPrice=Max(O, Ref(H - L,-1) + TickSize);
  > >> >
  > >> > Sell=BarsSince(Entry) > 1 AND O > Ref(C,-BarsSince(Entry));
  > >> > SellPrice=O;
  > >> >
  > >> > //And the obvious equivalents for Short trades
  > >> >
  > >> > ApplyStop(0,2,PickANumber,1,False);
  > >> >
  > >> > Those of you who once used Metastock will remember BarsSince
  > > (Entry),
  > >> > probably with great fondness and regret.  But you can't do
  that
  > > in AFL.
  > >> > You can't even do separate BarsSince(Buy) and BarsSince(Short)
  > >> > statements.  In AFL, your Sell statement becomes Sell=O >
  > >> > ValueWhen(Buy,BuyPrice,1);  And when you try to use ExRemSpan,
  > > there is
  > >> > every chance that you will land on another day where the Buy
  > > conditions
  > >> > are true.  At which point the ValueWhen function looks at that
  > > day's
  > >> > BuyPrice, and O is never higher.
  > >> >
  > >> > For a one-day delay, we can write two sell conditions, one for
  > > use if
  > >> > today is a Buy day and one for use if it is not, with
  different
  > > numbers
  > >> > for the third parameter in the ValueWhen statement.  But what
  if
  > > you'd
  > >> > like to set the delay for more than one day?  How many Sell
  > > conditions
  > >> > do you have to write to take care of all the possible
  > > combinations of
  > >> > Buy and non-Buy days since the entry?
  > >> >
  > >> > Two very talented programmers from our group were kind enough
  to
  > > attempt
  > >> > solutions to this problem for me, one in AFL, the other in ...
  I
  > > guess
  > >> > that was jScript.  I am very grateful to them for trying.
  > > However,
  > >> > neither succeeded.  In each case, trades that should have
  ended
  > > with a
  > >> > profit after two or three days were not exited until much
  later.
  > > In a
  > >> > test of the AFL version on continuous S&P data, the average
  trade
  > > length
  > >> > was just over 46 bars, and one trade lasted more than 600 bars!
  > >> >
  > >> > This is a very simple system, one of the most famous in all of
  > >> > traderporn.  It can be "coded" unambiguously in English.  With
  > >> > BarsSince(Entry), it could be coded unambiguously in
  Metastock;
  > > but MS
  > >> > would not give you valid entry and exit prices when I used it
  > > last; that
  > >> > was a major reason I was delighted when Tomasz made Amibroker
  > >> > available.  Unfortunately, one really useful thing from
  Metastock
  > > got
  > >> > left behind.  I understand that there are reasons for this.
  But
  > > those
  > >> > reasons are keeping me from testing this and several other
  ideas
  > > that
  > >> > might be of value.  Or they might not.  At this point, I have
  no
  > > way to
  > >> > know.
  > >> >
  > >> > I am profoundly sorry to keep pushing this, as I believe
  Tomasz
  > > created
  > >> > ExRemSpan in response to one of my early pleas for help in
  coding
  > > this
  > >> > exit.  And it could be that there is some way to use ExRem and
  > > ExRemSpan
  > >> > that actually solves the problem with the kind of generality
  I'm
  > > looking
  > >> > for, a technique that Tomasz knows but neither I nor my
  > > Samaritans were
  > >> > able to recognize.  But I'm betting against it.
  > >> >
  > >> > I have been trying to solve this problem for more than two
  years
  > > and am
  > >> > quite convinced that it cannot be done.  Tomasz, PLEASE HELP.
  > >> >
  > >> > Pretty please?  I'll finally get around to renewing my license
  if
  > > you
  > >> > do.  8-)
  > >> >
  > >> > Thanks to all for bearing with me on this.
  > >> >
  > >> > Owen Davies
  > >> >
  > >> >
  > >> >
  > >> > Check AmiBroker web page at:
  > >> > http://www.amibroker.com/
  > >> >
  > >> > Check group FAQ at:
  > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  > >> > Yahoo! Groups Links
  > >> >
  > >> >
  > >> >
  > >> >
  > >> >
  > >> >
  > >> >
  > >> >
  > >
  > >
  > >
  > >
  > >
  > >
  > > Check AmiBroker web page at:
  > > http://www.amibroker.com/
  > >
  > > Check group FAQ at:
  http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  > > Yahoo! Groups Links
  > >
  > >
  > >
  > >
  > >
  > >
  > >
  > >





  Check AmiBroker web page at:
  http://www.amibroker.com/

  Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


        Yahoo! Groups Sponsor
              ADVERTISEMENT





----------------------------------------------------------------------------
--
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

    b.. To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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