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

Re: [amibroker] Code help for foward looking execution in backtesting



PureBytes Links

Trading Reference Links

In a backtest you would be better to use high and low in your buy/sell
conditions instead of close. The close in historical bars is only one
value at the last price of that bar.

-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm



On 25/06/06, James <jamesmemphis@xxxxxxxxx> wrote:
> 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
>
>
>
> 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
>
>
>
>
>
>
>