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

Re: [amibroker] Deviation of open position value on last day


  • Date: Tue, 19 Jan 2010 14:28:49 +0100
  • From: "Markus Witzler" <funnybiz@xxxxxx>
  • Subject: Re: [amibroker] Deviation of open position value on last day

PureBytes Links

Trading Reference Links



Hello,
 
I found out what it is:
 
"position value" in trade list output in AA uses OPENING price of open positions whereas my trade.GetProfit() using CLOSING price.
 
But I still wonder what the reasoning is for using the open rather than the close???
 
Thanks
 
Markus
 
----- Original Message -----
Sent: Tuesday, January 19, 2010 2:15 PM
Subject: [amibroker] Deviation of open position value on last day

 

Hello,
 
I wonder why the following is happening:
 
After the i-incremented for loop of my low-level CBT code (which I displayed as a template below), I summed up the
value of all positions that were still open at end of backtest (variable "Last_open_position_value").
 
This variable (which to my understanding still contains marginloan) should correspond with column "position value" of trade list output for open positions, 
but it doesn´t. 
 
I added it as metric via bo.addcustommetric ("Last_open_position_value", Last_open_position_value) in backtest report to check for deviation.
 
Could someone let me know why the differ? I can´t see the flaw in my code.
 
Thanks
 
Markus
 
 
SetCustomBacktestProc("");
if (Status("action") == actionPortfolio)
{
    bo = GetBacktesterObject();	//  Get backtester object
    bo.PreProcess();	//  Do pre-processing
    for (i = 0; i < BarCount; i++)	//  Loop through all bars
    {
        for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
        {	//  Loop through all signals at this bar
            . . . .
        }	//  End of for loop over signals at this bar
        bo.HandleStops(i);	//  Handle programmed stops at this bar
        bo.UpdateStats(i, 1);	//  Update MAE/MFE stats for bar
        bo.UpdateStats(i, 2);	//  Update stats at bar's end
    }	//  End of for loop over bars

... Here comes the actual part of code that I am referring to:

for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())

{ // first variable should still include marginloan, right??

Last_open_position_value = Last_open_position_value + trade.GetPositionValue();

// second variable doesn´t contain marginloan, right??

Profit_open_positions_last_day = Profit_open_positions_last_day + trade.GetProfit();

}

Ending_equity = Profit_open_positions_last_day + bo.cash;

Starting_equity = bo.initialequity;

Total_portfolio_bars_in_datenum = StaticVarGet("last_bars_date",a[BarCount - 1]) - StaticVarGet("last_bars_date",a[0]);

bo.addcustommetric("Last_open_position_value", Last_open_position_value);

bo.addcustommetric("My_ending_equity", ending_equity);

bo.PostProcess(); // Do post-processing

}



__________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___