dt = DateTime();
ma20 = MA(C, 20);
// create folder for exporting purposes
fmkdir( "C:\\DataExport\\" );
// open file for writing
// file name depends on currently processed ticker
fh = fopen( "c:\\DataExport\\" + Name() + ".txt", "w" );
// proceed if file handle is correct
if ( fh )
{
// write header line
// fputs( "Ticker,Date/Time,Open,High,Low,Close,Volume,MA20\n", fh );
fputs( "Date/Time,Open,High,Low,Close,Volume,MA20\n", fh );
// iterate through all the bars
for ( i = 0; i < BarCount; i++ )
{
// write ticker name
//fputs( Name() + "," , fh );
// write date/time information
dtstr = DateTimeFormat( "%Y%m%d %H:%M,", dt[i] );
//write quotations and go to the next line
qs = StrFormat( "%g,%g,%g,%g,%g,%g\n", O[ i ], H[ i ], L[ i ], C[ i ], V[ i ], ma20[ i ] );
fputs( dtstr + qs, fh );
}
// close file handle
fclose( fh );
}
// line required by SCAN option
Buy = 0;