PureBytes Links
Trading Reference Links
|
Hello,
During a backtest, I want to dump the EntryDate, ExitDate, and Profit for each trade, to an external file.
Everything works except converting the DateTimes to strings. When it is dumped to file, I get "Invalid DateTime" for each of those entries.
Can anyone spot what is wrong here? Should be pretty straightforward:
FileName = "F:\\Test CBT.csv";
SetCustomBacktestProc( "" );
if ( Status( "action" ) == actionPortfolio ) { bo = GetBacktesterObject(); bo.Backtest( 1 );
for ( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) { Profit = Trade.GetProfit;
EntryDate = Trade.EntryDateTime; ExitDate = Trade.ExitDateTime;
EntryDateStr = DateTimeToStr( EntryDate ); ExitDateStr = DateTimeToStr( ExitDate );
fh = fopen( FileName, "a" );
if ( fh ) { fputs( EntryDateStr + "," + ExitDateStr + "," + StrFormat( "%.2f", Profit ) + "," + "\n", fh ); fclose( fh ); } }
bo.ListTrades(); }
fast = MA( Close, 5 ); slow = MA( Close, 25 ); Buy = Cross( fast, slow ); Sell = Cross( slow, fast ); Cover = Short = 0;
__._,_.___
**** 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/
__,_._,___
|