Hello, If you really must use different per-symbol commission the simplest way is *not* using custom backtester. Instead modify buy/sellprice by amount of per-share commission
BuyPrice = BuyPrice + CommissionPerShare; SellPrice = SellPrice - CommissionPerShare. The other way (using custom backtester) is explained in the User's Guide: http://www.amibroker.com/guide/a_custommetrics.html Use EXAMPLE 2 as a starting point. With few simple edits you have what you are asking for: /* First we need to enable custom backtest procedure and ** tell AmiBroker to use current formula */ SetCustomBacktestProc(""); /* Now custom-backtest procedure follows */ if( Status("action") == actionPortfolio ) { bo = GetBacktesterObject(); bo.Backtest(); // run default backtest procedure SumProfit = 0; // iterate through closed trades first for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) { Comm = 5; if( trade.Symbol == "GBP.USD-IDEALPRO-CASH" ) Comm = 20; // here we sum up profit minus commission SumProfit = trade.GetProfit() - Comm; NumTrades++; } // iterate through eventually still open positions for( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() ) { Comm = 5; if( trade.Symbol == "GBP.USD-IDEALPRO-CASH" ) Comm = 20; // here we sum up profit minus commission SumProfit = trade.GetProfit() - Comm; NumTrades++; } bo.AddCustomMetric( "Net profit", SumProfit ); } Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: "dralexchambers" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, May 30, 2007 5:40 PM Subject: No it is not, was: Re: [amibroker] Re: IS THIS A BUG: Strange things with Backtester > OK - there was no offense meant and my mistake for mentioning the > word bug. > > What I am trying to achieve is this: > > 1. Inside my custom backtest code, use the symbol name (eg: GBP.USD) > to determine the commission level for that symbol (an integer) > > 2. Then calculate the net profit (I already have this AFL working): > gross profit - commission cost > > 3. Output the net profit via: > bo.AddCustomMetric("net profit", netprofitvar); > > > I have the code for steps 2 and 3 already - it is Step 1 that I am > having problems with. > > Thanks, > Alex > > > > > 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 > > > > >
