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

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



PureBytes Links

Trading Reference Links

 y = Year()%100;

ds = StrFormat( "%02.f%02.f%02.f,", y[i], m[i], d[i] ); // date string
-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm



On 12/06/06, Lester Vanhoff <ebsn247lsm@xxxxxxxxxxxxx> wrote:
> > Graham> If you are wanting to export the data so you can use it in another package then use the export AFL rather than explorations.
>
> That's how I started but I couldn't figure out "c" code to get two digit year so I decided to try explorations first. Here is the looping code that generates the required data file (C:\Test\Ms_eod.csv) with four digit year. The question is how to change the following line to get yymmdd instead of yyyymmdd:
>
> ds = StrFormat( "%4.f%02.f%02.f,", y[i], m[i], d[i] );
>
> I tried these two options but both still give four digit year:
>
> ds = StrFormat( "%02.f%02.f%02.f,", y[i], m[i], d[i] );
> ds = StrFormat( "%2.f%02.f%02.f,", y[i], m[i], d[i] );
>
> Here is the full code:
>
> /****START****/
>
> folder = "C:\\Test";
> fmkdir( folder ); // this automatically creates the directory
>
> fh = fopen( folder + "\\" + "Ms_eod.csv", "a");
>
> if (fh)
> {
>   t = Name();
>   p = "D";
>   y = Year();
>   m = Month();
>   d = Day();
> for( i = 0; i < BarCount; i++ ) // loop
>   {
>   fputs( t + "," , fh );
>   fputs( p + "," , fh );
>   ds = StrFormat( "%4.f%02.f%02.f,", y[i], m[i], d[i] ); // date string
>   fputs( ds, fh );
>   qs = StrFormat("%.4f, %.4f, %.4f, %.4f, %.0f, %.0f\n", O[i], H[i], L[i], C[i], V[i], OI[i] ); // quote string
>   fputs( qs, fh );
>   }
> fclose( fh );
> }
> Buy = 0; // link to "scan" button
>
> /****END****/
>
>
> > On 12/06/06, Lester Vanhoff <ebsn247lsm@xxx> wrote:
> > > 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@> 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@> 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****/
>
>
>
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>