[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

Can can write a loop with your own buycond. Then you can, in the loop,
remember where you are relative to each entry. You can also keep track of
whether youıre on a buy or not, or if you have recently exited due to your
stop on an older buycond.

AFTER your loop is complete and you have all your buycond and sellcond then
execute the back test with:

Buy = buycond;
Sell = sellcond;

However, you are re-entering more often than your 7 day exit allows so,
unless you can change that, youıll just be back in on the next buy anyway.
This could be handled in the loop so you donıt take another Buy signal for x
days after an exit, but that doesnıt seem right either. Maybe you need
pyramiding so you track each Buy position on itıs own merits. Pyramiding is
not available yet, but can be simulated with PositionSize().
-- 
Terry


From: Owen Davies <owen5819@xxxxxxxxxxxx>
Reply-To: amibroker@xxxxxxxxxxxxxxx
Date: Sun, 31 Oct 2004 18:15:53 -0500
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Bars since Buy signal - how to code in AFL ?

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


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
 <http://us.ard.yahoo.com/SIG=129g83os7/M=315388.5543473.6613715.3001176/D=g
roups/S=1705632198:HM/EXP=1099350957/A=2372354/R=0/SIG=12id813k2/*https://ww
w.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>


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
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
*  
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .




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