[Attachment(s) from David Fitch included below]
Bistrader provided some code the other day
that has been helpful to understand CBT and Trace. Its been modified to
look at closed trades as well as open positions. The below CBT AFL, places
ExitPrice in the closed Trade list even though the trade is "Long Open". For
Example, running QQQQ, from 6/1/2009 to 9/17/2009, gives this result in
AA
QQQQ
Long
7/15/2009 36.92 8/10/20009
39.6
QQQQ
OpenLong 9/9/2009
41.09
9/17/2009 42.41
The entire Trace log is attached. The part of
interest is 9/10/2009 and below. At this point, LongOpen occurs with
EntryPrice 41.09 ( from Open Position List) and ExitPrice 39.60( from Close
Trade List). These two prices then begin alternating on subsequent days. I
suspect from comments made earlier from Bruce Robinson, that LongOpen forces a
"close daily" which can be problematic. But in addition, it holds the
previous ExitPrice, 39.60, from 8/10/2009, not current ExitPrice.
I speculate that this ExitPrice is the one used by
CBT in all metrics associated with LongOpen positions. Is this true? Does it
make sense?
This has been long winded. If its not clear please
let me know.
Thanks
Dave
SetCustomBacktestProc("");
if ( Status( "action" ) ==
actionPortfolio ) //2nd phase of
portfolio backtest
{
bo = GetBacktesterObject();
bo.PreProcess();
barDates = DateTime();
for ( bar = 0; bar < BarCount;
bar++ )
{
bardate = bardates[bar];
for ( trade = bo.GetFirstOpenPos();
trade; trade = bo.GetNextOpenPos() ) //TRade obj from Open Position List
{
_TRACE(NumToStr( barDate, formatDateTime ) +" EntryPrice " + NumToStr( trade.EntryPrice,
8.2 )+" " );
}
for(trade = bo.GetFirstTrade();
trade ; trade = bo.GetNextTrade() ) //Trade Obj from Closed Trade List
{
_TRACE(
NumToStr(barDate,formatDateTime ) +" ExitPrice "+ NumToStr( trade.ExitPrice, 8.2) );
}
bo.ProcessTradeSignals( bar );
}
bo.PostProcess();
}
Short = Cover = 0;
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Attachment(s) from David Fitch
1 of 1 File(s)
__._,_.___
**** 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/
__,_._,___
|