Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
Hello, :-) Well, if you calculate closing equity the way I described, you won't need low level. Best regards, Tomasz Janeczko amibroker.com On 2010-07-16 19:34, rise_t575 wrote: > > Thanks for this additional info. > > I just was thinking something like "My very first CBT code and I have to u

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
Thanks for this additional info. I just was thinking something like "My very first CBT code and I have to use low level... That's what I call bad luck..." --- In amibroker@yahoogroups.com, Tomasz Janeczko wrote: > > Hello, > > One more thing to add: as an alternative to going low-level, yo

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
Yes, correct - that's exactly what I am trying - completely overriding normal spsPercentOfEquity. Your reply also clears up the question if using UpdateStats() within the barcount loop *and* calling ProcessTradeSignals() thereafter would be equal to using UpdateStats() twice per bar - which s

Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
Hello, One more thing to add: as an alternative to going low-level, you could iterate through open positions list on your own (GetFirstOpenPos/GetNextOpenPos) get number of shares (Shares property) and multiply by Close price (trade object has GetPrice(bar, "C") method for that), then add to

Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
Hello, Generally speaking you should be using low-level backtest for that. Guessing from your rather short descriptions, I think that you are trying to override normal spsPercentOfEquity position size processing and use your own. The example codes for using low-level interface are included at

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
One last question for clarification: 1) On one hand, I have to call bo.ProcessTradeSignals() for updating equity. 2) On the other hand, I have to calculate position sizes *before* calling bo.ProcessTradeSignals(). 3) But for calculating the correct position sizes, my position sizing code has t

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
Tomasz, Great explanation - thanks! In fact, you could add this explanation regarding TimeInsideBar to the UpdateStats() section of the AB manual as well. It's a great help in order to understand things better. --- In amibroker@yahoogroups.com, Tomasz Janeczko wrote: > > Hello, > > You ca

Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
Hello, You can call UpdateStats( bar, 2 ) but please call it once per bar. When TimeInsideBar = 2 two things in addition to updating equity happen: a) interest earnings are added (from free cash) b) position exposure and portfolio stats are calculated You can get incorrect exposure figures if

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
I see - thanks. Actually I would like to use equity calculated from closing prices of the current bar (by searching the web, I've found that normally, AB calculates equity for position sizing with opening prices of the current bar - and not being aware of this has caused me some major headach

Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
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

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
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 amibroker@yahoogroups.com, Tomasz Janeczko wrote: > > Hello, > > The value of

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
Btw - could you (or someone else) tell me where these equity values within the AA Results list (Detailed Log) are derived from that are stated after e. g. "ENTER LONG,..." lines? Thanks. --- In amibroker@yahoogroups.com, "rise_t575" wrote: > > > > Tomasz, > > Thanks for this info - I'll d

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread rise_t575
Tomasz, Thanks for this info - I'll definitely check it out. I think a lot of such problems originate from a lack of *complete* understanding how CBT (or a complete backtest for that matter) *internally* works, i. e. what AB is processing and when, in which order, where exactly does CBT code

Re: [amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-16 Thread Tomasz Janeczko
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 eq

[amibroker] Re: Incorrect value of bo.Equity ...? AB ALWAYS using equity of previous bar PS

2010-07-15 Thread rise_t575
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 debu