This code I have written is forward looking. I believe
the backtester is waiting until the end of a bar is
completed to determine if the close is above/below the
entry/stop. I would like for it to execute at the
market. I used BuyPrice, ShortPrice, SellPrice, and
CoverPrice to try and get the correct execution price,
but the problem is occurring when the high/low of a
bar exceeds a stop but then reverses and closes on the
other side. The backtester does not execute on this
bar, because the close does not meet the criteria. I'm
sure there is a simple way to correct this, but I
could not find it. Simplified code is:
EntryBars = Param("Entry Bars", 15, 1, 30, 1);
ExitBars = Param("Exit Bars", 5, 1, 30, 1);
BuyUpper = HHV(Ref(H,-1),EntryBars);
SellLower = LLV(Ref(L,-1),EntryBars);
StopUpper = HHV(Ref(H,-1),ExitBars);
StopLower = LLV(Ref(L,-1),ExitBars);
Buy = Cross (Close, BuyUpper);
Short = Cross (SellLower, Close);
Sell = Cross (StopLower, Close);
Cover = Cross (Close, StopUpper);
BuyPrice = Max (BuyUpper, Low);
ShortPrice = Min (SellLower, High);
SellPrice = Min (StopLower, High);
CoverPrice = Max (StopUpper, Low);
It is my understanding that in real time, Close would
act as Last, but that is not happening in the
backtest. Any ideas on how to fix this problem or
could someone kindly point me to a documented
solution?
TIA,
James
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.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:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/