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

[amibroker] Backtest errors in losing trades



PureBytes Links

Trading Reference Links

Hi all,

I've writtena  absic backtest to buy a stock if it closes in the lower
5% of the day's trading range and then sell it at the open the next
day.  It works fine except that in losing trades, it sells at the LOW
price of the entry day instead of the OPEN price of the following day.
 Here's my code:

/*Backtest for stock when closing in lowest 5% of day and selling at
next day's open*/

/*Variables*/

BarHeight = High - Low ;

OneOneHundredth = BarHeight / 100;

PercentClose2 = Optimize ("Percentage High", 5, 5, 20, 1);

UpperMargin = Low + (PercentClose2 * OneoneHundredth); /*change the
number in this line to whatever percentage you want to backtest*/

/*Backtest*/

Buy = 

Close <=  Uppermargin ;

BuyPrice = Close;

Sell = Ref (Open, 1) > 0.01 ;

SellPrice = Ref (Open, 1) ;

/*end of code*/


Can anyone debug this for me??  It's probably something simple!  I've
got my trades settings at Buy Price = Close; Sell Price = Open; Buy
Delay = 0; Sell delay = 0; Allow Same Bar Exit is UNTICKED.  

Any help appreciated.
Chris



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