This document contains code to export stock market data from a specified start and end date range to a CSV file for later analysis. It sets the start and end bar indexes based on the given dates, opens a file handle, then loops through the bars writing the ticker, date, open, high, low, close and volume values to the CSV file. It closes the file after completing the export.
This document contains code to export stock market data from a specified start and end date range to a CSV file for later analysis. It sets the start and end bar indexes based on the given dates, opens a file handle, then loops through the bars writing the ticker, date, open, high, low, close and volume values to the CSV file. It closes the file after completing the export.
This document contains code to export stock market data from a specified start and end date range to a CSV file for later analysis. It sets the start and end bar indexes based on the given dates, opens a file handle, then loops through the bars writing the ticker, date, open, high, low, close and volume values to the CSV file. It closes the file after completing the export.
This document contains code to export stock market data from a specified start and end date range to a CSV file for later analysis. It sets the start and end bar indexes based on the given dates, opens a file handle, then loops through the bars writing the ticker, date, open, high, low, close and volume values to the CSV file. It closes the file after completing the export.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 2
// Set the Starting and End Dates
// Make sure these dates are not holidays.
StartDate = ParamDate("Starting Date", "31-12-2007"); EndDate = ParamDate("Start Date", "31-12-2008"); //Find the corresponding Bar Numbers StartBar = Max(0, LastValue(ValueWhen(DateNum() == StartDate, BarIndex(),1))); EndBar = Min(BarCount - 1, LastValue(ValueWhen(DateNum() == EndDate, BarIndex(),1))); Filter = 1; // This allows all required data to be included // Before running the AFL Make sure that C:\SaveData directory exists fh = fopen( "c:\\SaveData\\"+Name()+".csv", "w"); if( fh ) { fputs( "Ticker,Date,Open,High,Low,Close,Volume \n", fh ); y = Year(); m = Month(); d = Day(); //r = Hour(); //e = Minute(); //n = Second(); for( i = StartBar; i <= EndBar; 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:%02.0f,",
//r[ i ],e[ i ],n[ i ] );
//fputs( ts, fh ); qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n", O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] ); fputs( qs, fh ); } fclose( fh ); } // The following lines are redundant but are required for the Exploration to work. // These lines will just output the data being written to the file. SetOption("NoDefaultColumns", True); AddTextColumn(Name(), "Symbol", 77); AddColumn(DateTime(), "Date", formatDateTime); AddColumn(O, "Open", 6.2); AddColumn(H, "High", 6.2); AddColumn(L, "Low", 6.2); AddColumn(C, "Colse", 6.2); AddColumn(V, "Volume", 10.0); //******************* END OF AFL ********************
how to use it...
click this afl...when a chart open > click auto analyser >select all symbols & all quotations (may be it done by default...is not then you do this ) >click explore..............>click file-export....name a file and save...
Backtesting Control Points - What's The Calculation - What's The Solution - Profitable Trading Strategies - MQL4 and MetaTrader 4 - MQL4 Programming Forum