Hello, It can be as simple as:
ValueWhen( Buy, HHV( C, 20 ) ); but you need to describe FINAL goal that you are after, so actually best solution can be offered Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: justjuice200 To: [email protected] Sent: Wednesday, February 13, 2008 2:39 AM Subject: [amibroker] Backtesting and Custom Metrics: How to determine HHV at date of Buy? 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(); }
