http:\/\/www.amibroker.com\/kb\/2006\/03\/04\/how-to-export-quotations-from-amibroker-to-csv-file\/<\/a> already explained how to use exploration to export quotes into a single text \/ CSV file. <\/p>If, for some reason, we need individual files for each symbol, AmiBroker offers another way of writing data to text files. This can be achieved by using fputs<\/strong> function that would write directly to external files. Using fputs<\/strong> allows us also to fully control formatting of the output data and file naming can be dynamically set based on Name<\/strong>() function output.<\/p>To perform the export procedure, we need to run a Scan<\/strong> over the list of symbols we want to export data for.<\/p>In the Analysis->Formula Editor<\/strong> please enter the following code:<\/p><\/span>\/\/ create folder for exporting purposes
<\/span>fmkdir<\/span>( <\/span>"C:\\\\DataExport\\\\" <\/span>);
<\/span>\/\/ open file for writing
\/\/ file name depends on currently processed ticker
<\/span>fh <\/span>= <\/span>fopen<\/span>( <\/span>"c:\\\\DataExport\\\\" <\/span>+ <\/span>Name<\/span>() + <\/span>".txt"<\/span>, <\/span>"w" <\/span>);
<\/span>\/\/ proceed if file handle is correct
<\/span>if ( <\/span>fh <\/span>)
{
<\/span>dt <\/span>= <\/span>DateTime<\/span>();
<\/span>\/\/ write header line
<\/span>fputs<\/span>( <\/span>"Ticker,Date\/Time,Open,High,Low,Close,Volume\\n"<\/span>, <\/span>fh <\/span>);
<\/span>\/\/ iterate through all the bars
<\/span>for ( <\/span>i <\/span>= <\/span>0<\/span>; <\/span>i <\/span>< <\/span>BarCount<\/span>; <\/span>i<\/span>++ )
{
<\/span>\/\/ write ticker name
<\/span>fputs<\/span>( <\/span>Name<\/span>() + <\/span>"," <\/span>, <\/span>fh <\/span>);
<\/span>\/\/ write date\/time information
<\/span>fputs<\/span>( <\/span>DateTimeToStr<\/span>( <\/span>dt<\/span>[ <\/span>i <\/span>] ) + <\/span>","<\/span>, <\/span>fh <\/span>);
<\/span>\/\/write quotations and go to the next line
<\/span>qs <\/span>= <\/span>StrFormat<\/span>( <\/span>"%g,%g,%g,%g,%g\\n"<\/span>, <\/span>O<\/span>[ <\/span>i <\/span>], <\/span>H<\/span>[ <\/span>i <\/span>], <\/span>L<\/span>[ <\/span>i <\/span>], <\/span>C<\/span>[ <\/span>i <\/span>], <\/span>V<\/span>[ <\/span>i <\/span>] );
<\/span>fputs<\/span>( <\/span>qs<\/span>, <\/span>fh <\/span>);
}
<\/span>\/\/ close file handle
<\/span>fclose<\/span>( <\/span>fh <\/span>);
}
<\/span>\/\/ line required by SCAN option
<\/span>Buy <\/span>= <\/span>0<\/span><\/code>Now please select Tools->Send to Analysis<\/strong>, select the list of symbols (e.g. Apply To: Filter<\/strong>, pick the watchlist in the Filter<\/strong> dialog), set Range<\/strong> to All Quotations<\/strong>, and press Scan<\/strong><\/p>","protected":false},"excerpt":{"rendered":"The following KB article: http:\/\/www.amibroker.com\/kb\/2006\/03\/04\/how-to-export-quotations-from-amibroker-to-csv-file\/ already explained how to use exploration to export quotes into a single text \/ CSV file. If, for some reason, we need individual files for each symbol, AmiBroker offers another way of writing data to text files. This can be achieved by using fputs function that would write directly to […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[53,14,31],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/702"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":2,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"predecessor-version":[{"id":721,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/702\/revisions\/721"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}