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