Hello, Sorry, the method name is actually UpdateStats()
Best regards, Tomasz Janeczko amibroker.com On 2010-07-16 14:06, rise_t575 wrote: > > Probably I'm blind, but I cannot find any information about the mentioned > UpdateEquity() function, any searches in the online/offline manual result > nothing. Could someone provide me with a link? > > Thanks. > > > --- In [email protected], Tomasz Janeczko<gro...@...> wrote: >> Hello, >> >> The value of bo.Equity is correct. >> >> And your findings are incorrect. >> "Use previous bar equity" works as described in the manual. >> >> You are making mistake in your thinking/debugging. >> Your formula is checking bo.Equity BEFORE calling ProcessTradeSignals(). And >> it is giving you last known >> equity value. That is the reason of your incorrect findings. >> >> If you are using custom backtester interface, there are clearly defined >> points where *you* are in charge >> and when AB is in charge (and can update anything). It will NOT do any >> "magical steps" out of blue right after >> for( bar = 0; bar< BarCount; bar++ ) loop. If you want to update equity to >> the current bar you either >> must call ProcessTradeSignals() (it will update equity and process >> signals) OR... if you want to have >> current bar equity WITHOUT calling ProcessTradeSignals, you have to call >> UpdateEquity( bar, 0 ) function. >> >> The difference that "Use previous bar equity" makes in case of CBT is that >> ***INSIDE*** ProcessTradeSignals() >> it will use either previous bar or current bar equity, depending on setting, >> and it will affect the size >> of position open (if you are using spsPercentOfEquity or otherwise depend on >> available equity) >> >> Recommended reading: >> http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/ >> >> >> Best regards, >> Tomasz Janeczko >> amibroker.com >> >> On 2010-07-15 20:15, rise_t575 wrote: >>> Hi, >>> >>> I've just found out what is happening, but I have not the slightest idea >>> why. >>> >>> The backtester is *always* using previous bar equity for positions sizing, >>> although this setting is *not* ticked, and I haven't included the >>> corresponding SetOption function. >>> >>> In fact, the backtests and the debugging logs are exactly identical when >>> UsePrevBarEquityForPosSizing is True and when it is False. >>> >>> Is this some bug or isn't that setting being used when using CBT for >>> position sizing? >>> >>> Thanks in advance! >>> >>> --- In [email protected], "rise_t575"<rise_t@> wrote: >>>> Hello, >>>> >>>> The following are the (debug) outputs of a tested position sizing >>>> algorithm. >>>> >>>> I've attached a) part of the code , b) the output of the _TRACE() function >>>> from within the CBT code (the TRACE function had been placed within the >>>> most inner "if{}" code block), and c) the output of the AA Results window >>>> (Detailed Log). >>>> >>>> Note that on the _TRACE() output, the equity on day 2 (21.01.2000) is >>>> still at its intial value (100000), so it hasn't been adjusted for price >>>> changes of the position taken at the close of day 1 (which did exist). >>>> >>>> Since this equity value is used for calculation of the position size of >>>> subsequent signals, this is a problem. >>>> >>>> On the other hand, the output of the AA Results windows on day 2 is >>>> correct (99823.2) >>>> >>>> And - no - "Use previous bar equity for position sizing" is not activated. >>>> >>>> Does anyone have an idea why bo.equity delivers incorrect values in this >>>> case? >>>> >>>> Thanks in advance! >>>> >>>> Part of CBT code in question: >>>> >>>> for ( sig = bo.GetFirstSignal( bar ); sig; sig = >>>> bo.GetNextSignal( bar ) ) >>>> { >>>> if ( sig.IsEntry() ) >>>> { >>>> currEquity = bo.Equity; >>>> pointVal = sig.PointValue; >>>> cbtAtr = StaticVarGet( "statAtr" + sig.Symbol ); >>>> psUnits = int( currEquity * ( pctVolaRisk / 100 >>>> ) / ( cbtAtr[bar] * pointVal ) ); >>>> [_TRACE] >>>> sig.PosSize = ( 2000 + psUnits ) * -1; >>>> } >>>> } >>>> >>>> >>>> >>>> DebugView Output: >>>> [2856] Date: 20.01.2000 Symbol: FDRY Equity: 100000 Cash: 100000 ATR: >>>> 14.383258 Units: 69 >>>> [2856] Date: 21.01.2000 Symbol: PCLN Equity: 100000 Cash: 89818.2 ATR: >>>> 27.671930 Units: 36 >>>> [2856] Date: 21.01.2000 Symbol: TYC Equity: 100000 Cash: 89818.2 ATR: >>>> 14.318740 Units: 69 >>>> [2856] Date: 25.01.2000 Symbol: AKAM Equity: 98382.8 Cash: 59163.1 ATR: >>>> 27.247997 Units: 36 >>>> [2856] Date: 03.02.2000 Symbol: IBM Equity: 97308.7 Cash: 49107.9 ATR: >>>> 4.628230 Units: 210 >>>> [2856] Date: 04.02.2000 Symbol: FDRY Equity: 97846.4 Cash: 42716.2 ATR: >>>> 13.667122 Units: 71 >>>> >>>> >>>> AA Results Output: >>>> 20.01.2000 >>>> Entry signals(score):FDRY=Buy(1), >>>> Exit signals: >>>> Enter Long, FDRY, Price: 147.563, Shares: 69, Commission: 0, Rank: 1, >>>> Equity 100000, Margin Loan: 0, Fx rate: 1 >>>> 1 Open Positions: , FDRY (+69), Equity: 100000, Cash: 89818.2 >>>> >>>> 21.01.2000 >>>> Entry signals(score):PCLN=Buy(1), TYC=Buy(1), >>>> Exit signals: >>>> Enter Long, PCLN, Price: 381, Shares: 36, Commission: 0, Rank: 1, >>>> Equity 100237, Margin Loan: 0, Fx rate: 1 >>>> Enter Long, TYC, Price: 245.493, Shares: 69, Commission: 0, Rank: 1, >>>> Equity 100237, Margin Loan: 0, Fx rate: 1 >>>> 3 Open Positions: , FDRY (+69), , PCLN (+36), , TYC (+69), Equity: >>>> 99823.2, Cash: 59163.1 >>>> >>>> 24.01.2000 >>>> Entry signals(score): >>>> Exit signals: >>>> 3 Open Positions: , FDRY (+69), , PCLN (+36), , TYC (+69), Equity: >>>> 98382.8, Cash: 59163.1 >>>> >>>> 25.01.2000 >>>> Entry signals(score):AKAM=Buy(1), >>>> Exit signals: >>>> Enter Long, AKAM, Price: 279.313, Shares: 36, Commission: 0, Rank: 1, >>>> Equity 98825.1, Margin Loan: 0, Fx rate: 1 >>>> 4 Open Positions: , FDRY (+69), , PCLN (+36), , TYC (+69), , AKAM >>>> (+36), Equity: 98806.8, Cash: 49107.9 >>>> >>> >>> >>> ------------------------------------ >>> >>> **** 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 >>> >>> >>> >>> > > > > ------------------------------------ > > **** 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 > > > >
