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