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

[amibroker] Re: How To Get Two Digit Year In Exploration



PureBytes Links

Trading Reference Links

Thanks, Graham, but your code has the same issue of exploration returning the date of the last available quote in all rows (see below). If you can't figure this out then I'm starting to lose my hope.

I just want to look at my Metastock ver.4.51rt (for DOS) and need ASCii with two digit year. Updating to a bit newer version is obviously not an option.

Lester

/****START****/

Filter = 1;

yy = Year();
mm = Month();
dd = Day();

ThisDate = StrFormat( "%4.f%02.f%02.f",yy,mm,dd );

SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker");
AddColumn(DateTime(), "Real Date", formatDateTime);
AddTextColumn(ThisDate, "yyyymmdd");

/****END****/

--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>
> Try this as one method
> yy = Year();
> mm = Month();
> dd = Day();
> ThisDate = StrFormat( "%4.f%02.f%02.f",yy,mm,dd );
> 
> -- 
> Cheers
> Graham
> 
> On 11/06/06, Lester Vanhoff <ebsn247lsm@xxx> wrote:
> >
> > 1) Thanks, Wavemechanic, but when you use Year(), Month() and Day() and then run exploration with the date range set to, let's say, last 15 quotations all the rows will have the same date (the date of the last quote). In the formula below I included the column "Real Date"; compare it with columns "yyyy", "mm", "dd".
> >
> > 2) Another question is: how to get month and day with leading zeros?
> >
> > Lester
> >
> > /****START****/
> >
> > Filter = 1;
> >
> > yy = NumToStr(Year(),1.0,0);
> > mm = NumToStr(Month(),1.0);
> > dd = NumToStr(Day(),1.0);
> >
> > SetOption("NoDefaultColumns", True);
> > AddTextColumn(Name(), "Ticker");
> > AddColumn( DateTime(), "Real Date", formatDateTime );
> > AddTextColumn( yy, "yyyy");
> > AddTextColumn( mm, "mm");
> > AddTextColumn( dd, "dd");
> > AddTextColumn(yy+mm+dd, "yymmdd");
> >
> > AddColumn( Close, "Close", 1.4 );
> > AddColumn( Volume, "Volume", 1.0 );
> >
> > /****END****/
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "wavemechanic" <fimdot@> wrote:
> > >
> > > Note that DateTime() returns an array which you are treating as a string.
> > > Recode with Year(), Month(), and Day() and then you can manipulate to
> > > produce the output that you want.
> > >
> > > ----- Original Message -----
> > > From: "Lester Vanhoff" <ebsn247lsm@>
> > > >
> > > > 1) The following exploration works ok:
> > > >
> > > > Filter = 1;
> > > > SetOption("NoDefaultColumns", True);
> > > > AddTextColumn(Name(), "Ticker");
> > > > AddColumn( DateTime(), "Date&Time", formatDateTime );
> > > > AddColumn( Close, "Close", 1.4 );
> > > > AddColumn( Volume, "Volume", 1.0 );
> > > >
> > > > 2) Now if you try to get two-digit year instead of four-digit year the
> > > > formula returns an error (the date format on my computer is set to
> > > > yyyy-mm-dd):
> > > >
> > > > /***START***/
> > > >
> > > > Filter = 1;
> > > >
> > > > yy = StrMid(DateTime(),2,2); //start=char#2 (zero based), length=2 char
> > > > mm = StrMid(DateTime(),5,2);
> > > > dd = StrMid(DateTime(),8,2);
> > > >
> > > > SetOption("NoDefaultColumns", True);
> > > > AddTextColumn(Name(), "Ticker");
> > > > AddColumn( DateTime(), "Date&Time", formatDateTime );
> > > > AddTextColumn(yy+mm+dd, "yymmdd");
> > > >
> > > > AddColumn( Close, "Close", 1.4 );
> > > > AddColumn( Volume, "Volume", 1.0 );
> > > >
> > > > /***END***/
> > > >
> > > > The solution might be to place DateTimeToStr() or StrToDateTime()
> > > > somewhere there. As a non-programmer I still can't get the feel for all
> > > > those strings, numbers, arrays, etc.