There is one more issue here. The formula is set to export the last two days of 
eod data for each symbol (to C:\ZZ\Mseod.csv). If you export a group of symbols 
and one of them doesn't have 2 bars of eod data but just one bar (new ticker, 
like IPO) then the export will stop with an error message.

The solution is probably to add another line with BarIndex() or BarCount 
somewhere in there:

if (BarIndex() > 0)

In short, I want to export the last two days of data for all tickers that have 
two days of data and one day of data for tickers which have only one day 
available.

Here is the code:

/*** START ***/

output_folder = "C:\\ZZ";
output_file   = "Mseod.csv";

fh = fopen( output_folder + "\\" + output_file, "a");
if (fh)
{
  t = Name();
  y = Year()%100;
  m = Month();
  d = Day();
for( i = BarCount - 2; i < BarCount; i++ )
  {
  fputs( t + "," , fh );
  ds = StrFormat( "%02.0f%02.0f%02.0f,", y[i], m[i], d[i] );
  fputs( ds, fh );
  qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f,%.0f\n", O[i], H[i], L[i], C[i], 
V[i], OI[i] );
  fputs( qs, fh );
  }
fclose( fh );
}
Buy = 0;

/*** END ***/


--- In [email protected], "Tomasz Janeczko" <[EMAIL PROTECTED]> wrote:
> 
> Change
> for( i = 0; i < BarCount; i++ )
> 
> to
> 
> for( i = BarCount - 2 ; i < BarCount; i++ )
> 
> Best regards,
> Tomasz Janeczko

> ----- Original Message ----- 
> From: "Lester Vanhoff" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, January 02, 2007 5:37 PM
> Subject: [amibroker] Exportt To ASCii: How To Limit Number Of Bars In The 
> Loop?
> 
> 
> > Here is a sample code that exports eod data from AB to "ticker.CSV" files 
> > in C:\ZZ folder (based on Graham's article in AFL 
> > Library). How to limit the number of days exported from the current "all 
> > available" to just two days. I would obviously need to 
> > modify this line, but I don't have a clue how this "BarCount" loop really 
> > works:
> >
> > for( i = 0; i < BarCount; i++ )


Reply via email to