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

[amibroker] Re: How to exit a stock when quotes end?



PureBytes Links

Trading Reference Links


Graham,

Thank you very much.  Your code didn't work as-is (it caused an exit 
the day after every entry) but your use of LastValue led me to a new 
round of experimentation that led to a solution.  At first I 
identified the last bar by Close==EndValue(Close) AND High==EndValue
(High)...etc.  That's workable and I was able to get the backtester 
to not enter a position on the last bar and to close any open 
positions on the last bar.  The only drawback was that any bar with 
the same OHLC as the last bar would get the same treatment.  My 
revised solution avoids that problem:   

x=Cum(1)==LastValue(Cum(1)); // last bar
y=Cum(1)!=LastValue(Cum(1)); // not the last bar
Buy = Close<(1.3*BBandBot(Close,10,1.5)) AND y; // don't buy last bar
Buy = ExRemSpan( Buy, 10 );
Sell = Ref( Buy, -10 ) OR x;	// sell after 10 days or at close of 
last bar
Capital = 100000;  
PositionSize = -5;

The solution seems surprisingly simple now but it's still a fair 
accomplishment for my pea-sized Amibroker brain.  Thanks for your 
help.

Wayne


--- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> Have you tried something like this
> 
> Exit = ( Now(3) - lastvalue( datenum() ) ) > 10;
> 
> Cheers,
> Graham
> 





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