Here is an expert to provide bid-ask prices as the ticks arrive.
It is a modification of the work done by Andrey Khatimlyanskyy on
www.mql4.com where he explained data storage.
There are 4 files:
log2.mq4 & log2.ex4
log ticks.mq4 & log ticks.ex4
Place the log2 files in the \experts\include folder.
Place the log ticks files in the \experts folder.
Add the log ticks expert to the chart with the symbol you want to collect bid-ask data.
There is an option for local time or broker time in the expert. TimeisLocal = true gives local time, =false gives broker time. (In IBFX broker time is GMT).
The expert will generate one file per calendar day. You will have to combine files for multiple days, but it offers some protection from creating a HUGE file. If you want, you can modify the log2.mq4 to adjust this for a single file or multiple days.
The resulting text file is located in the \experts\files folder.
The file is a text file with the name in the format
"Acct No Tick-Bid-Ask--date.txt"
Example: 1261643 Tick-Bid-Ask--2006.11.07.txt
The data is csv in the format shown below:
Time,Bid,Ask
13:07:52,1.9092,1.9097
13:07:52,1.9092,1.9096
13:07:53,1.9091,1.9096
13:07:59,1.9092,1.9096
13:07:59,1.9092,1.9097
13:08:00,1.9093,1.9097
13:08:09,1.9092,1.9097
13:08:12,1.9092,1.9096
Time,Bid,Ask
19:08:22,1.9092,1.9096
19:08:22,1.9092,1.9097
19:08:23,1.9092,1.9096
19:08:28,1.9091,1.9096
19:08:32,1.9090,1.9095
This is a copy & paste from a single text file where I changed from local time to broker time after the expert started.
Note that each time the expert restarts, i.e. changing inputs, changing time frames, opening & closing metatrader, and probably other activities, the expert is restarted and the header line is put in the text file (Time,Bid,Ask).
If you want to collect data, the best choice is to set this and let it run continuosly for the desired time. Or, you will need to ensure you clean out these headers before using the data. I suspect, but haven't confirmed, that you could miss data points when you restarted the expert.
Hope this helps, and thanks to Andrey for the initial concept and code.
P.S. to Gert... Cap'n Jack works, but eagles is faster to type.