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

Re: [amibroker] Re: BarsSince(Buy)AFL for Newbies and Dummies ...was



PureBytes Links

Trading Reference Links

Hello Tomasz,

I would like to make a few comments/suggestions concerning this matter, 
which IMO is of prime importance.

1 - No simplification in an explanation or description  is superfluous. In 
other words there is no "too simplistic" an explanation.
In fact examples  descriptions and explanations are for people who have 
(supposedly) no knowledge of programming.On the other hand examples cannot 
go to extreme simplicity as that would take too much space and time to read. 
So for example something like your explanation, from the library, in 
"Automatic Trendline" or "Double Top Detection" to describe the use of the 
CUM function or VALUEWHEN function.

2 - Define or describe words or at least give examples for words such as: 
Boolean, Bit-wise, Logical, etc.
e.g. What is the difference between:  AND and   &.
or !=  and  NOT ?   etc.

3 - In my use of Excel as a Newbie, I was surprised to find that my best 
learning was through the use of a booklet titled:
"Excel 5 for Windows - Instant Reference. In fact whenever I had a certain 
application, I went to the appropriate chapter, e.g.
....Editing, Engineering Functions, Exiting Excel, File Formats, Filling 
Ranges, Filters, Financial Functions, Finding Files....
Each, in this case, being a page or two more or less. Again this is a 
personal experience.

These were a few comments jotted down for further thought.

Regards,

Herbert


----- Original Message ----- 
From: "Tomasz Janeczko" <amibroker@xxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, November 13, 2004 12:12 PM
Subject: Re: [amibroker] Re: BarsSince(Buy)


>
> 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@xxxxxxxxx>
> 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
>>> >
>>> >




------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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/