Hello Mike, I try to do the following:
I want to code a routine for having my own version of equity computed for every day (bar) that the backtest is composed of rather than just for every signal/trade. The components (at this point) are: daily cash position plus the value of all open trades, determined bs their close (i.e. positionsize * closing price) You may argue that this is already done by amibroker, but later, I intend to modify the code to substitute the value of all open positions with their respective sell-stop (i.e. trailing-stop) values of all open positions. Additionally, I see the problem to have my version of equity (let´s call it my_equity) not being computed on days where there might be no trades, open trades or signals since CBT -as I understand it- is not run in context of individual bars but of signals, trades!? Thus, I wonder how to tell CBT still to compute my equity (which then is merely cash position on days with no open trades) to store it as addtocomposite to be later able to plot is as an indicator. Do you know what I mean? Appreciate your help a lot Markus ----- Original Message ----- From: Mike To: [email protected] Sent: Sunday, November 08, 2009 7:42 AM Subject: [amibroker] Re: Value of all open positions in CBT Are you trying to show the total value combined of all open positions? If so, you should be setting your custom metric on the backtester object itself (i.e. bo.AddCustomMetric(...), rather than on the individual trades. If you're trying to set it on the individual trades, then just set the value of that single trade (i.e. getPositionValue), not the values of all trades up to that point. Also, the backtest report, and thus the custom metrics, are as of the last day of the analysis period. So, the values you see will not be "for any given day". If you truely want "for any given day", then add the individual positon values to a composite and plot the composite. Mike --- In [email protected], "Markus Witzler" <funny...@...> wrote: > > Hello, > > I have trouble finding coming up with the proper code for determining the value of all open positions for any given day (determined by the close!) > > Is it this: > > for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos()) > { > Value_open_positions = Value_open_positions + trade.GetPositionValue() > trade.AddCustomMetric ("Open Position Value", trade.Value_open_positions); > } > Incidentally, GetPositionValue doesn´t indicate if it uses closing prices. > > > > > > __________ Information from ESET Smart Security, version of virus signature database 4581 (20091107) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > __________ Information from ESET Smart Security, version of virus signature database 4582 (20091107) __________ The message was checked by ESET Smart Security. http://www.eset.com
