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

[amibroker] Re: Help with converting DateTimes in CBT



PureBytes Links

Trading Reference Links

I should add that I restored my PC system defaults for all date and time settings, and that made no difference. So that's not the culprit.

Is there a setting in AB specific to DateTime that I'm not aware of? Can't find anything in the manual that could account for this.


--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> Really weird that it works for you, and not for me. I can't think of any
> other setting that could possibly affect this. And it's not just dumping
> to file that does not work. As a test, I can't add a datetime as a
> custom metric to the backtester report. The string shows up as "Invalid
> DateTime". If I try to add it as a number, it shows up as "0.0":
> 
>          EntryDate    = Trade.EntryDateTime;
>          EntryDateStr = DateTimeToStr(EntryDate);
> 
>          Trade.AddCustomMetric( "EntryDate" ,EntryDateStr    );
> 
> 
> Of course I know that the entry date column already exists in the
> backtester report. I'm just doing this as a test, after the dump to file
> did not work.
> 
> Is this a possible bug in AB 5.28.1?
> 
> I don't recall ever having any problems with DateTime conversions in
> previous versions, and I've done stuff like this before.
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> wrote:
> >
> > Thanks, Mike. That's interesting. I had changed my PC system time
> format to be compatible with some VBscript programs I needed to run.
> That might be the culprit, although DateTime works fine within Amibroker
> itself. It's only when I try to dump to file that it gets screwed up.
> >
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "sfclimbers" sfclimbers@ wrote:
> > >
> > > Your code works fine, as published, for me. Perhaps inconsistent
> environment settings between AmiBroker generating the date and whatever
> you're using to open the generated file (e.g. American form vs.
> Australian)?
> > >
> > > Mike
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> wrote:
> > > >
> > > > 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/

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/