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

[amibroker] Re: Backtesting and Custom Metrics: How to determine HHV at date of Buy?



PureBytes Links

Trading Reference Links

Tomasz,

That depends a bit on exactly what you want when it comes to a
"certain number of bars". If the stock in question has unpadded data
holes relative to the alignment index, then the number of bars from
buy points, or the exact values of MAs, etc, might be different in the
backtester to the original stock chart.

If that's not critical that's fine, but if it is, then I think ATCs
are needed (short of having static arrays).

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>
> For what is worth: it is best to use Pad and align option in the AA
 Settings 
> whenever you use portfolio backtest. Then you get consistent results
all the time
> regardless of data holes and you don't need to do any ATC.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "vlanschot" <vlanschot@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Wednesday, February 13, 2008 12:30 PM
> Subject: [amibroker] Re: Backtesting and Custom Metrics: How to
determine HHV at date of Buy?
> 
> 
> > Sorry to jump in here, GP, but instead of ATC, can I not get to the 
> > HHV via:
> > 
> > for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) 
> > {
> > TradeName=trade.symbol;
> > 
> > HiHiV20 = HHV(Foreign(TradeName,"C"),20);
> > 
> > . . . .
> > }
> > 
> > I've always done it like this, but wonder whether this alignment is 
> > an issue then ???
> > 
> > PS
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@> 
> > wrote:
> >>
> >> One issue you have is that by calculating the HHV in the custom
> >> backtest procedure, the results may not be the same as if it were
> >> calculated in the main AFL code. That's because the Foreign function
> >> aligns the stock to the bar dates of the backtester, and 20 custom
> >> backtest bars may not be the same as 20 bars of the original stock
> >> chart. To get around that, you need to calculate HHV in the main AFL
> >> and then pass it to the backtester using AddToComposite.
> >> 
> >> To then get the values you want on the entry dates, you could just
> >> note the value on each entry date as the entries are processed,
> >> storing them in dynamic variables or possibly in a writeable unused
> >> field of the Trade object. Otherwise, as you run through the closed
> >> trades, you could get the entry date/time and search for that
> >> date/time in the relevant HHV array (using Foreign again to get the
> >> HHV array).
> >> 
> >> For the price a certain number of bars from the entry date, you have
> >> the same problem of bar realignment in the custom backtester. If
> >> you've removed redundant buy signals in the main AFL code, you could
> >> perhaps create a BarsSince(Buy) array, pass that to the custom
> >> backtester as an ATC, and use that to find which bar in the custom
> >> bactester is the correct number of bars from the buy (assuming it's
> >> after the buy date and not before).
> >> 
> >> Regards,
> >> GP
> >> 
> >> 
> >> --- In amibroker@xxxxxxxxxxxxxxx, "justjuice200" <justjuice200@> 
> > wrote:
> >> >
> >> > I know this should be simple, but can't figure out how to code it 
> > in
> >> > AFL.  Many thanks in advance.
> >> > 
> >> > I want to add some custom metrics to the backtest report.  For 
> > each
> >> > trade, I want to show two things:
> >> > 1) a 20-bar HHV at the date of the buy
> >> > 2) a price at a certain number of bars away from the date of the 
> > buy.
> >> > 
> >> > So far what I have is the following (and not sure I'm on the right
> >> > track either):
> >> > 
> >> > if (Status("action") == actionPortfolio){
> >> >      bo=GetBacktesterObject();
> >> >      bo.Backtest(1);
> >> > 
> >> > for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
> > {
> >> >              ticker=trade.Symbol();
> >> >              symbolPriceArray=Foreign(ticker, "C", 1);
> >> >              Dateoftrade=trade.EntryDateTime();
> >> >              BarNumOfTrade=....some Code Here...
> >> >              myHigh=HHV(symbolPriceArray,20)/*Also need some way 
> > to
> >> > define the
> >> >                      HHV with reference to the date of the buy*/
> >> > 
> >> >              CloseTenDaysAgo=symbolPriceArray[BarNumOfTrade-10];
> >> > 
> >> >          }
> >> > 
> >> >          bo.ListTrades();
> >> > 
> >> > }
> >> >
> >>
> > 
> > 
> > 
> > 
> > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > Yahoo! Groups Links
> > 
> > 
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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