[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

y = Year()%100;

Thanks a lot, Graham, that's the key, it solved the problem. Can anyone suggest a link with some info about "c" string formatting (all those %f, %e, %g, %100, etc.)

I have another question but I'll start another thread:

"How to overwrite exported CSV data file"

Lester


>Graham <kavemanperth@xxx> wrote:
>
>  y = Year()%100;
> 
> ds = StrFormat( "%02.f%02.f%02.f,", y[i], m[i], d[i] ); // date string
>
> 
> On 12/06/06, Lester Vanhoff <ebsn247lsm@xxx> 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****/