PureBytes Links
Trading Reference Links
|
Hi,
Using the mid and low level backtester, trades get added/removed to/from the lists on a bar by bar basis at the point where the respective signals get processed (e.g. bo.ProcessTradeSignals(i) in mid level backtester).
Once taken, open trades remain in the open list, possibly spanning multiple bar indices, until they are closed. When closed, the trades are moved to the closed list and will remain there for the duration of the backtest.
A trade does not appear in any list until a signal is accepted by the backtester (e.g. the lists at bar 100 will not contain a trade that only gets opened at bar 110). Once taken, it will always be accessible in one of the lists from that point forward. If necessary, you can write code to monitor the lists on a bar by bar basis to track the trade activity.
The bar index of the trade entry/exit is not stored as part of the trade object. But, the entry/exit dates are. Using that information you could calculate the bar index if you really needed it.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@xxx> wrote:
>
> Hello,
>
> I have trouble understanding trade lists (open/closed) in custom backtester.
>
> As opposed to signal lists which carry an index variable and thus only process signals for a specific bar, trade lists haven´t.
>
> Consider the following code template in low-level CBT mode
> 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
> for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
> {
> . . . .
> }
> for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())
> {
> . . . .
> }
> 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
> bo.PostProcess(); // Do post-processing
> }
> I understand, that each run, signal list is being processed for a different value of "i". But how is trade list being used. Since there is no index variable "i", I can´t figure out if trade objects are being searched for a different value of "i" than in signal list, or if whole list of trades (for all bars) is being processed at each occurrence of "i" in the main loop.
>
> Can someone help me clear this up?
>
> Thanks
>
> Markus
>
------------------------------------
**** 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/
|