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

Re: [amibroker] Bars since Buy signal - how to code in AFL ?



PureBytes Links

Trading Reference Links

ed nl wrote:

>here I put the code how to do this. ...
>Buy = LLV(L,6) == L AND C > Ref(C,-1);
>Buy = Ref(Buy,-1);
>BuyPrice = O;
>
>Sell = BarsSince(Buy) == 7; (etc.)
>
How would you code the exit if you had a Buy signal that can be repeated 
frequently?  For example, say you want to write a Larry Williams-style 
breakout system:

Buy=H >= Fraction * Ref(H-L,-1);
BuyPrice=Max(O,Fraction * Ref(H-L,-1) + TickSize);

The usual answer is to use ExRemSpan(), as you did, but look at what 
happens if you use the "bailout" exit Williams recommends:  Wait one 
bar, and then exit on the first profitable Open, with a wide stop-loss 
to take care of the failures.  (Incidentally, I don't mean to suggest 
that either half of this system could be profitable in today's markets; 
it's just a well-known example of the kind of thing that gives me 
problems.)  Without ExRemSpan(), your standard of profitability changes 
every time the entry signal is repeated. But ExRemSpan(Buy,1) won't fix 
the problem. either. It will skip the necessary bar, but then the same 
problem comes back. If the next Open doesn't trigger the profit-taking 
exit and you get another entry signal during the day, that day's 
BuyPrice again replaces the one where you actually entered.

Very short-term trading interests me most, so I run into this kind of 
thing a lot, not only with the bailout exit but with several other ideas 
that seem worth testing. I have found work-arounds for a few very 
specific circumstances, but nothing that is generally applicable.

MetaStock used the BarsSince(Entry) function to solve the problem. I 
believe Tomasz was kind enough to supply ExRemSpan() in response to my 
need for an equivalent some time ago and rather suspect that he now 
thinks I'm an idiot for not understanding that it does the job. But if 
ExRemSpan() or the combination of ExRemSpan() and ExRem() works for this 
I probably am an idiot, because I really can't see it.

BarsSince(Entry) really did make this kind of logic very easy to code.  
(Sigh.)

Any insights or ideas, anyone?

Thanks.

Owen Davies


------------------------ 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/