PureBytes Links
Trading Reference Links
|
I was only addressing how to shorten Anthony's code.
My attitutude is "You don't need no damn loops". ;-)
> Darn! That presupposes that I already have the Sell and Cover
> conditions. I can't see how to use this for an exit condition like this:
> Sell=Days > N AND ExitCondition;
The way around this it to delay defining your Buy and Sell arrays 'til the
very end. Something like this (I've prefaced the Buys and Sells names with
"r" to inidicate "raw" signals.
rBuy=BuyCondition; // Replace with your actual definitions
rSell=SellCondtion;
rShort=ShortCondition;
rCover=CoverCondition;
Long=Flip(rBuy,rSell);
Shrt=Flip(rShort,rCover);
Days = IIf(Long,BarsSince(Cross(Long,0.5)),0);
Sell = Days > N AND ExitCondition; // now works!
// you can now define the actual Buy array to satisfy the backtester
Buy = rBuy; // just a copy of the "raw" signals
I'm sure you get the idea...
----- Original Message -----
From: "Owen Davies" <owen5819@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, 1 November 2004 9:31 AM
Subject: Re: [amibroker] Bars since Buy signal - how to code in AFL ?
Paul Chivers wrote:
>Here's a shorter version without the loops.
>
>
>Buy = Cross( MACD(), Signal());
>Sell=Cross(Signal(),MACD());
>
>Long = Flip(Buy,Sell);
>
>Days = IIf(Long,BarsSince(Cross(Long,0.5)),0);
>
Hmmm. Can I do this?
Buy=BuyCondition;
Sell=SellCondtion;
Short=ShortCondition;
Cover=CoverCondition;
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Darn! That presupposes that I already have the Sell and Cover
conditions. I can't see how to use this for an exit condition like this:
Sell=Days > N AND ExitCondition;
Am I missing something?
I am deeply grateful for your help.
Owen
------------------------ 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/
|