Patrick, I am signing off now for some z's but a quick second opinion on your question (can't help the first caller with the custom backtest report though).
I am not sure what timeframe you mean - if it is intraday my comments won't help much. I have done some work in the past with missing bars (EOD) and managed to get around it using array code (maybe you have too but I am not sure if you mean that you handle it in AFL by nominating the dates or by identifying missing bars). I have used a few different ways in AFL to identify or handle EOD missing bars (other than entering dates for holidays from an international calendar). First it varies with providers - if they pad missing days themselves and how they do it. In that case I find them by using identifiers like - if the previous O,H,L,C all equal todays OHLC then it is more than likely padded - repeating the previous bar is one way that providers pad missing EOD data (of course sometimes an identical bar or no vol just means that it is a thinly traded stock but I don't want them in my stock list anyway). I don't always like NoVol as a test for padded bars because some times the bar is padded by the provider with volume included and sometimes the indexes don't have volume. Another thing I do (for backtesting EOD) is filter out stock that has less than the annual number of bars - theoretically it does bias results but then so does missing data (in my case I only want to trade highly liquid stock anyway so I am comfortable about filtering out junk stock with missing bars. I also filter out stock that has too many identical bars (lightly traded) - I have found this to be a better liquidity filter than vol*price (for my purposes). Also I have used code, in conjunction with Pad&Align, to identify which bars are padded by AmiBroker - the padded bar leaves a characteristic trail that you can code for (from memory I think it is a null - I did that work last year, or the year before, and the memory fades a bit - I have notes on it somewhere). Also I am cautious about using the index as the Pad&Align reference - I have found cases where the indexes are padded on public holidays etc - sometimes I do an exploration with barcount and use the number that is the most common i.e. if the index has 250 bars for the year but 200/500 stocks in my database had 251 bars for the year I use 251, in code, as the becnhmark for a stock with no missing data and/or I select one of the stocks from the 251 bar list as the reference stock for P&A. Not sure if that is the type of thing you are after - as I said it depends on how accurate your providers data is, what padding they do and how you want to use it. brian_z --- In [email protected], "vlanschot" <[EMAIL PROTECTED]> wrote: > > But that doesn't solve the non-trading (holi)days during the work- > week which differ per market, nor does it facilitate MENA-region > markets where they trade from Sunday to Thursday, etc. > > I don't want to be a pain, it's just something I'm confronted with, > and always need to 1) point out as one of the caveats in my BT- > results, or 2) adjust in my AFL-code (by excluding those dates per > market, which IS a pain). > > PS > --- In [email protected], "Tomasz Janeczko" <groups@> > wrote: > > > > How about using artificial ticker that just holds all Mon-Fri days? > > > > Best regards, > > Tomasz Janeczko > > amibroker.com > > ----- Original Message ----- > > From: "vlanschot" <vlanschot@> > > To: <[email protected]> > > Sent: Wednesday, February 13, 2008 12:41 PM > > Subject: [amibroker] Re: Backtesting and Custom Metrics: How to > determine HHV at date of Buy? > > > > > > > Thanks Tomasz, > > > > > > There remains one problem with this, at least as far as I'm aware > and > > > as far as it concerns my situation: I look at multiple > international > > > markets with different trading dates (i.e. holidays). I therefore > > > need to "pad&align" to various "benchmarks" at the same time, > > > depending on what market the particular symbol trades. Therefore > my > > > obvious request: can this be expanded? > > > > > > Thx, > > > > > > PS > > > > > > --- In [email protected], "Tomasz Janeczko" <groups@> > > > 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@> > > >> To: <[email protected]> > > >> 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 [email protected], "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 [email protected], "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 > > > > > > > > > > > >
