I don't totally understand your logic because it looks like you're looping
through each bar of the same symbol BarCount times, but to create a separate
file for each symbol you could make the symbol name a part of your file
name:

 

  fh = fopen( "C:\\OHLC\\OHLC" + Name() + ".txt", "a"); 



Regards,

 

David:

 

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Tony Lei
Sent: 03/31/2007 3:32 PM
To: [email protected]
Subject: [amibroker] Exporting data to ASCII format question

 

Hi,

I am using this AFL code to help me export data from AB into ASCII to be
used by another software.  But it creates only 1 text file for all the
symbols (130 US stocks).  How can I make AB create 1 file for every symbol
or 130 text files in my OHLC folder? Any help is appreciated, 

thanks

Qitrader


///////////////////Code/////////////////////////////

fmkdir( "C:\\OHLC" );
Buy = ( (DateNum() >= 1051225) AND (DateNum() <= 1070330) );
for( i = 0; i < BarCount; i++ ) 
if( Buy[i] )
{
  fh = fopen( "C:\\OHLC\\OHLC.txt", "a"); 
  if( fh ) 
   { 
     y = Year(); 
     m = Month(); 
     d = Day(); 
     r = Hour();
     e = Minute();
   
   for( i = 0; i < BarCount; i++ )
   if( Buy[i] )

   { 
      fputs( Name() + "," , fh );
      ds = StrFormat("%02.0f%02.0f%02.0f,", 
                     y[ i ], m[ i ], d[ i ] ); 
      fputs( ds, fh ); 
     
      ts = StrFormat("%02.0f:%02.0f,", 
                     r[ i ],e[ i ]); 
      fputs( ts, fh ); 

      qs = StrFormat("%.2f,%.2f,%.2f,%.2f,%.0f\n", 
                     O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] ); 
      fputs( qs, fh );
   }
      fclose( fh );
   }
}

 

Reply via email to