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

[amibroker] Re: CBI: bo.InitialEquity to set value not working?



PureBytes Links

Trading Reference Links

That's the way I want it to work, too.  :)

It's behaving here as if it really is read-only, as documented in the Portfolio Backtester Interface Reference -- or my code is wrong.

Here's some code.  In the Equity pane, the equity value increases by 1 on each bar (correct) but never is set to 100.  Report shows initial equity from AA, not 100.

Best regards,

/////////////////
Buy=Sell=Short=Cover=0;
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
	bo = GetBacktesterObject();
	bo.PreProcess();

	bo.Equity = 100; // not visible in Report or Equity pane

	for( bar = 0; bar < BarCount-1; bar++ )
	{
		bo.Cash += 1; // visible in Equity pane & AA Report
		bo.ProcessTradeSignals( bar );
	}// for bar

	bo.PostProcess();

}// if actionPortfolio
/////////////////

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>
> Hello,
> 
> Technically it is not read-only (i.e. writing is allowed) but note that
> equity will be overwritten every bar with calculated value equal to
> (CASH + MARKET VALUE OF OPEN POSITIONS).
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "markhoff" <markhoff@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, May 01, 2008 5:52 PM
> Subject: [amibroker] Re: CBI: bo.InitialEquity to set value not working?
> 
> 
> > 
> > Hi Tomasz,
> > 
> > I also tried to set the equity by using bo.Equity, but also this did
> > not work (I tried both before and after bo.PreProcess). The manual
> > says that Equity property is read-only.
> > 
> > Best regards,
> > Markus
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@> wrote:
> >>
> >> Hello,
> >> 
> >> Initial Equity is used to INITIALIZE equity at the start of the
> > backtest,
> >> nothing more. So even if you write to it, it has no effect because
> >> Equity is already initialized when you call GetBacktesterObject.
> >> 
> >> If you want to affect the equity (including equity at the start of
> > backtest)
> >> use Equity property instead.
> >> 
> >> Best regards,
> >> Tomasz Janeczko
> >> amibroker.com
> >> ----- Original Message ----- 
> >> From: "markhoff" <markhoff@>
> >> To: <amibroker@xxxxxxxxxxxxxxx>
> >> Sent: Thursday, May 01, 2008 2:36 PM
> >> Subject: [amibroker] CBI: bo.InitialEquity to set value not working?
> >> 
> >> 
> >> > Hi,
> >> > 
> >> > I wonder if the CBI property bo.InitialEquity cannot be used to set
> >> > the initial equity. At least for me it does not work and I must use
> >> > the SetOption("InitialEquity", ...) command, although the
> >> > documentation does not say that the bo.InitialEquity is read-only.
> >> > 
> >> > Please see the code below:
> >> > 
> >> > --- cut ---
> >> > 
> >> > defaultPosSize = 1000;
> >> > 
> >> > InitialEquity = 123456;
> >> > 
> >> > Buy = Sell = Short = Cover = 0;
> >> > 
> >> > SetOption("UseCustomBacktestProc", True);
> >> > 
> >> > //SetOption("InitialEquity", InitialEquity);
> >> > 
> >> > SetCustomBacktestProc(""); 
> >> > 
> >> > // the trading rules
> >> > TwentyBarHHV = Ref(HHV(High, 20), -1);
> >> > Buy = High > TwentyBarHHV;
> >> > Sell = Ref(Buy, -10);
> >> > // cleanup excessive signals
> >> > Buy = ExRem( Buy, Sell );
> >> > Sell = ExRem( Sell, Buy );
> >> > 
> >> > if( Status("action") == actionPortfolio )
> >> > {
> >> > bo = GetBacktesterObject();
> >> > 
> >> > _TRACE("# bo.InitialEquity (default) = " + bo.InitialEquity);
> >> > _TRACE("# bo.Equity (default) = " + bo.Equity);
> >> > 
> >> > bo.InitialEquity = InitialEquity;
> >> > 
> >> > _TRACE("# bo.InitialEquity (updated) = " + bo.InitialEquity);
> >> > _TRACE("# bo.Equity (updated) = " + bo.Equity);
> >> > 
> >> > bo.PreProcess();
> >> > 
> >> > _TRACE("# bo.InitialEquity (after bo.PreProcess) = " +
> > bo.InitialEquity);
> >> > _TRACE("# bo.Equity (after bo.PreProcess) = " + bo.Equity);
> >> > 
> >> > for( bar = 0; bar < BarCount; bar++ )
> >> > {
> >> > for( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal(
> >> > bar ) )
> >> > {
> >> > // cash and equity are only correct if SetOption() is used to set
> >> > InitialEquity
> >> > _TRACE("# " + sig.Symbol + " : Cash = " + bo.Cash);
> >> > _TRACE("# " + sig.Symbol + " : Equity = " + bo.Equity);
> >> > 
> >> > if(sig.IsEntry())
> >> > {
> >> > sig.PosSize = defaultPosSize ;
> >> > }
> >> > }
> >> > bo.ProcessTradeSignals( bar );
> >> > }
> >> > bo.PostProcess();
> >> > }
> >> > 
> >> > --- cut ---
> >> > 
> >> > Do you have any idea why bo.InitialEquity cannot be used to write
> > a value?
> >> > 
> >> > Thanks in advance and best regards,
> >> > Markus
> >> > 
> >> > 
> >> > 
> >> > ------------------------------------
> >> > 
> >> > 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
> > 
> > 
> >
>



------------------------------------

**** 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/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/