[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: Trade lists vs. signal list in custom backtester



PureBytes Links

Trading Reference Links



Hi Mike,
 
sorry for getting back so late.
 
Your comments shed some light on my probs.
 
If I may, a few more things need to be clarified:
 
1. In the CBL low.level loop below, will the signal loop be processed for one instance of "i", then the following trade loop (open and closed trades). Afterwords, i gets incremented by one and the whole starts again?
 
2. If so, did I understand you correctly that closed and open trade lists hold ALL closed (respectively open) trades that have been generated by signals (from signal list) up to the value "i" holds for any given moment? I.e. if "i" holds the value of "10" the trade lists (open or close) hold ALL trades up to that bar even though the bar number is now beign store but the date (entry and exit)?
 
3. The command "postprocess" in mid- and low-level turns signals into trades and thus moves them from one list to the other?! But then the postprocess comand should stand beetween signal and trade list, right. Otherwhise the shift would occur the NEXt time the loop is being processed?!
 
4. You wrote" If necessary, you can write code to monitor the lists on a bar by bar basis to track the trade activity" - could you givew me a short clue what to do? Would I have to used "list trades" and "updatestats" in each run of the loop after each trade?
 
5. You wrote "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." I may be interested how to do this as well. A short hint would be fine.

I don´t wnat to make it more complex than it is, but I sometimes just don´t understand the inner workings of CBT and thus can´t come up with the proper code.
 
Sorry for my ignorance!
 
Markus
 
 
 
 
----- Original Message -----
From: Mike
Sent: Thursday, October 29, 2009 12:36 AM
Subject: [amibroker] Re: Trade lists vs. signal list in custom backtester

 

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@xxxxxxxxxps.com, "Markus Witzler" <funnybiz@xx.> 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___