• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 11:44am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:44am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Export All pairs or selected pairs to .csv with script 3 replies

Help - indicator data export .csv 3 replies

Export mt4 data to different columns of a .csv file 1 reply

Export RSI data to a csv file? 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 11
Attachments: Data export to CSV
Exit Attachments

Data export to CSV

  • Last Post
  •  
  • Page 1 2
  • Page 1 2
  •  
  • Post #1
  • Quote
  • First Post: May 2, 2009 9:45pm May 2, 2009 9:45pm
  •  ra457
  • | Joined Mar 2007 | Status: Sleep deprived | 81 Posts
I've been looking at this and I can't figure out what I'm doing wrong!

I modified an existing script to handle more pairs and omit the moving average data when sending info to a .csv file.

I'll attach the original and my edit and just hope someone can take the time to see which parameter I'm missing. I'm sure it's an easy fix somewhere but I'm new to programming and I think I just need another set of eyes to look at it.

Thank you in advance,

R
Attached Files
File Type: mq4 Daily Data FILE.mq4   10 KB | 1,973 download
File Type: mq4 Rich_daily_explort.mq4   15 KB | 1,334 download
  • Post #2
  • Quote
  • May 3, 2009 12:45am May 3, 2009 12:45am
  •  ra457
  • | Joined Mar 2007 | Status: Sleep deprived | 81 Posts
I removed all the array-related commands and referenced the OHLCV directly but am still receiving the same error.

Can someone look at this and tell me if the filewrite command is correct?

I'm still getting

')' - wrong parameters count(147, 6)

Thanks in advance...

R
Attached File
File Type: mq4 [EXPORT].mq4   9 KB | 1,169 download
  • Post #3
  • Quote
  • May 3, 2009 2:58am May 3, 2009 2:58am
  •  ra457
  • | Joined Mar 2007 | Status: Sleep deprived | 81 Posts
The FileWrite command can only use 63 parameters at a time. I had 75 (O,H,L,C & V for 15 pairs) and needed to break it into 2 separate commands. I did need to get rid of the array commands from the original script as they were useless for my purposes. Anyway, I hope someone else can use this. Just drag and drop the script from the navigator (Ctrl+N) onto any chart and it will export the OHLCV data from the previous day to expertsfilesDaily_Base.csv .

This is going to save me so much time!!!
Attached File
File Type: mq4 [EXPORT].mq4   9 KB | 1,800 download
  • Post #4
  • Quote
  • May 3, 2009 10:32am May 3, 2009 10:32am
  •  Kenz987
  • Joined Aug 2006 | Status: Member | 737 Posts
You can get around the parm count limit by placing all the data in a string before the write, then just write 1 string. However, there might be a limit on the length of the string - I don't know.
  • Post #5
  • Quote
  • Sep 12, 2010 6:59pm Sep 12, 2010 6:59pm
  •  mt4trader
  • | Joined Oct 2009 | Status: Junior Member | 4 Posts
Hi Ra457,

Thanks for sharing your code. I would like to export historical data from MT4 to .csv, but I don't want to have to open up the platform manually each time to do this.

If possible, I would like a VB script that could open the MT4 application, perhaps triggered by a scheduler event, then run the MQ4 script after that to export the data.

I'd like to hear from anyone who may have tried something similar.

Thanks,

mt4coder
  • Post #6
  • Quote
  • Dec 20, 2012 1:09pm Dec 20, 2012 1:09pm
  •  qubbit
  • | Commercial Member | Joined Feb 2012 | 17 Posts
you can try to use QB-DataExporter. It works only with MT5
you can download from here
http://goo.gl/QvvX6
  • Post #7
  • Quote
  • Jan 20, 2015 11:18am Jan 20, 2015 11:18am
  •  freak11
  • | Joined Mar 2010 | Status: Member | 7 Posts
Hi,
I am also looking for an automatic export. I know that you can manually export history files on metatrader and save them as csv. files but I want a code that does it automatically every 15 minutes. How can I do that?
  • Post #8
  • Quote
  • Jan 21, 2015 12:40am Jan 21, 2015 12:40am
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,081 Posts
Quoting freak11
Disliked
Hi, I am also looking for an automatic export. I know that you can manually export history files on metatrader and save them as csv. files but I want a code that does it automatically every 15 minutes. How can I do that?
Ignored
Most of what appears below has been copied from another post. Since MT4 build 600, I'm no longer undertaking any coding or troubleshooting requests, hence if the attached indicator doesn't do the required job, you'll need to get a programmer write another indicator for you. I have not included the source code (.mq4 file), because it will not compile correctly in builds later than 509.

Now I will disappear back into hibernation.


Output History indicator

This will output OHLCV history to CSV files, simultaneously for up to 40 pairs/instruments, and 9 timeframes, allowing easy import to Excel. A separate file is created for each pair/timeframe combination. The indicator runs it once every time a new candle starts to form on the RefreshPeriod, overwriting the relevant file(s).

Each bar in the chart occupies one line (row) in the file. Data in each row is output in the following order: date/time, open, high, low, close, volume


INSTALLATION:

Copy the .ex4 (indicator) file into your ..../MQL4/Indicators folder.
Then restart MT4.


PARAMETERS:

CurrencyPairs: leave blank to output only for the pair on whose chart the script/indicator is attached. Otherwise type in up to 40 pairs, separated by commas. Upper or lowercase doesn’t matter, and you may use the following abbreviations: A=AUD, C=CAD, F=CHF, E=EUR, G=GBP, J=JPY, N=NZD, U=USD. Hence you could type something like: EU,GU,UF,UJ which works the same as EURUSD,GBPUSD,USDCHF,USDJPY

TimeFrames: leave blank to output only for the timeframe on whose chart the script/indicator is attached. Otherwise type in up to 9 timeframes, separated by commas. Upper or lowercase doesn’t matter. For example, to output for all 9 timeframes, copy this:
M1,M5,M15,M30,H1,H4,D1,W1,MN

Hence the above entries would create 36 different files (4 pairs x 9 timeframes).

DifferentSubfolderPerTimeFrame: if set to FALSE, all files will be output to your …/MQL4/Files folder. If set to TRUE, subfolders will automatically be created under this folder, e.g. …/MQL4/Files/H1, and the output file(s) will be created in the subfolders.

Regardless of the folder, all files are named: [pair],[timeframe].CSV

LookbackBars: OHLCV values for the most recent (rightmost) ‘n’ bars will be output, where ‘n’ is the value you type here. If you specify either 0, or a very large number (e.g. 999999), then all values for all bars in the chart history will be output.

DescendingDateTimeOrder: if set to FALSE, data is output in chronological order, i.e. earliest bar values at the start of the file. If set to TRUE, data is output in reverse chronological order, i.e. most recent bar values at the start of the file.

OutputHeaderLine: if set to TRUE, it will output one line (row), with column headings, at the start of the file. If set to FALSE, no header line will be output.

FieldSeparator: set this to the delimiter character(s) you wish to appear between column vales that are outputs. Default is a comma (,). Type a caret (^) character if you want fields, including those in the header line, to be separated by tabs.

EncloseValuesInQuotes: if set to TRUE, each data value will be enclosed in double quotes, e.g. “1.3659”.

DateTimeFormat, PriceFormat, etc: these are explained here.
Note that date and time, by default, are output as one field. If you want them to appear as separate fields, you must include a field separator (and quotes, if desired) inside the DateTimeFormat, e.g. M/D/Y","H:I

RefreshPeriod: leave as +0 and the indicator will overwrite the file(s) with updated data every time a new candle on the current chart starts to form. Or type M1 or M5 etc to have the indicator overwrite the files whenever a new candle on that timeframe starts to form. Or simply type T to have it overwrite the files on every new price tick (warning: this can slow down your computer, if you're outputting data for a large number of lookback candles).


NOTE: There may be problems (like no data being output) if you have the output file open in both MT4, and Excel, simultaneously. This is because MT4 requires exclusive access to the file. Opening the file in Excel in read only mode may solve the problem; it depends on which version of Excel you're running.


SAMPLE OUTPUT:

Inserted Code
Date,Time,Open,High,Low,Close,Volume
"12/21/2012","04:00","87.970","87.984","87.584","87.804","18961"
"12/21/2012","08:00","87.803","87.965","87.582","87.609","15917"
"12/21/2012","12:00","87.607","87.847","87.560","87.603","12136"
"12/21/2012","16:00","87.602","87.871","87.530","87.686","18678"
"12/21/2012","20:00","87.686","87.724","87.538","87.599","7838"
"12/24/2012","00:00","87.707","87.870","87.652","87.734","9248"
"12/24/2012","04:00","87.736","87.818","87.687","87.813","4924"
"12/24/2012","08:00","87.810","87.915","87.780","87.811","5634"
"12/24/2012","12:00","87.812","87.891","87.741","87.811","6903"
"12/24/2012","16:00","87.811","87.994","87.793","87.938","5883"
"12/26/2012","01:00","88.053","88.412","88.006","88.348","13701"
"12/26/2012","05:00","88.348","88.476","88.308","88.398","7351"
"12/26/2012","09:00","88.398","88.608","88.347","88.433","10198"
"12/26/2012","13:00","88.433","88.642","88.350","88.576","10997"
"12/26/2012","17:00","88.576","88.770","88.427","88.766","12260"
"12/26/2012","21:00","88.766","88.842","88.715","88.837","4481"
"12/27/2012","00:00","88.833","88.886","88.620","88.832","10180"
"12/27/2012","04:00","88.835","88.948","88.755","88.803","10334"
"12/27/2012","08:00","88.803","88.970","88.765","88.945","9994"
"12/27/2012","12:00","88.944","89.119","88.902","89.065","9441"
Attached File
File Type: ex4 Output History.ex4   32 KB | 2,317 downloads
1
  • Post #9
  • Quote
  • Jan 29, 2015 1:43am Jan 29, 2015 1:43am
  •  JohniJohni
  • | Joined Jan 2015 | Status: Junior Member | 1 Post
Hello My friends

I'm not sure I ask My question in Right place, but Im new here

Is there any website which have for example EURUSD M5 Excel file with long history for download? or only way is we should make it our self from MT4?

Thank you in Advance
  • Post #10
  • Quote
  • Jan 29, 2015 5:20am Jan 29, 2015 5:20am
  •  hukam
  • Joined Mar 2012 | Status: Member | 1,222 Posts
use this EA, it will help u to extract data from mt4, place it on M5 chart..
i have tested its working perfectly.
i think only way is mt4 or download form dukascopy history data.

.......
..
and also request to coders friends if anybody visit here....please add more options in source code.
option to save all pairs into one single excel time wise.
eg: like H1 - its should contain all pairs data from market watch.
H4 - its should contain all pairs data from market watch.
please enjoy it, incase any help you need please message me i will help up to my level.
Attached File
File Type: mq4 Currency_Loader.mq4   28 KB | 1,198 download
1
  • Post #11
  • Quote
  • Feb 5, 2015 8:18am Feb 5, 2015 8:18am
  •  cja
  • Joined Feb 2007 | Status: Member | 1,650 Posts
Quoting hukam
Disliked
use this EA, it will help u to extract data from mt4, place it on M5 chart.. i have tested its working perfectly. i think only way is mt4 or download form dukascopy history data. ....... .. and also request to coders friends if anybody visit here....please add more options in source code. option to save all pairs into one single excel time wise. eg: like H1 - its should contain all pairs data from market watch. H4 - its should contain all pairs data from market watch. please enjoy it, incase any help you need please message me i will help up to...
Ignored
Attached File
File Type: mq4 CurrencyLoader Script.mq4   28 KB | 961 downloads
Trade what you see not what you hope
1
  • Post #12
  • Quote
  • Feb 5, 2015 10:15pm Feb 5, 2015 10:15pm
  •  MarcusChin
  • | Joined Feb 2015 | Status: Member | 172 Posts
Hi, I got a stupid question. Sometime we have to day-back in the chart in order to download the historical price from broker. If we didn't do this task, will the script run properly without any data missing?

Thanks a lot.
  • Post #13
  • Quote
  • Apr 18, 2015 7:07pm Apr 18, 2015 7:07pm
  •  Lors1606
  • | Joined Apr 2015 | Status: Member | 4 Posts
Quoting hanover
Disliked
{quote} Most of what appears below has been copied from another post. Since MT4 build 600, I'm no longer undertaking any coding or troubleshooting requests, hence if the attached indicator doesn't do the required job, you'll need to get a programmer write another indicator for you. I have not included the source code (.mq4 file), because it will not compile correctly in builds later than 509. Now I will disappear back into hibernation. Output History indicator This will output OHLCV history to CSV files, simultaneously for up to 40 pairs/instruments,...
Ignored

Dear Hanover,

I need your help please. About your Output History.ex4, I want to set the default of "TimeFrames to D1", "LookbackBars to 9999999", "OutputHeaderLine to false", DateTimeFormat to Y.M.D,H:I", "PriceFormat to T5.5", PriceFormatJPYpairs to T5.5".
So, I don't have to spend a lot of time to change them.
Thank you for your kindness...
  • Post #14
  • Quote
  • Apr 20, 2015 1:09am Apr 20, 2015 1:09am
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,081 Posts
Quoting Lors1606
Disliked
{quote} Dear Hanover, I need your help please. About your Output History.ex4, I want to set the default of "TimeFrames to D1", "LookbackBars to 9999999", "OutputHeaderLine to false", DateTimeFormat to Y.M.D,H:I", "PriceFormat to T5.5", PriceFormatJPYpairs to T5.5". So, I don't have to spend a lot of time to change them. Thank you for your kindness...
Ignored
Change the parameter settings to your desired values, then save the chart as a template (menu option: Charts --> Template --> Save Template...)

Then simply re-load the template whenever you need to.
  • Post #15
  • Quote
  • Apr 20, 2015 1:40am Apr 20, 2015 1:40am
  •  Lors1606
  • | Joined Apr 2015 | Status: Member | 4 Posts
Hannover,

I feel more comfortable with your indicator: Output History.ex4
for exporting historical of all pairs to CSV file at the same time.



I hope you could help me by make default setting in Output History.ex4 script.


Attached Image (click to enlarge)
Click to Enlarge

Name: Screenshot5.png
Size: 66 KB



thanx alot.
  • Post #16
  • Quote
  • Apr 28, 2015 2:03am Apr 28, 2015 2:03am
  •  Lors1606
  • | Joined Apr 2015 | Status: Member | 4 Posts
Quoting hanover
Disliked
{quote} Change the parameter settings to your desired values, then save the chart as a template (menu option: Charts --> Template --> Save Template...) Then simply re-load the template whenever you need to.
Ignored
Dear Hannover

I feel more comfortable with your indicator: Output History.ex4
for exporting historical of all pairs to CSV file at the same time.



I hope you could help me by make default setting in Output History.ex4 script.


Attached Image (click to enlarge)
Click to Enlarge

Name: HANNOVER.png
Size: 151 KB


thanx alot
  • Post #17
  • Quote
  • May 25, 2015 2:33pm May 25, 2015 2:33pm
  •  mfunk
  • | Joined May 2015 | Status: Junior Member | 2 Posts
Hi Hanover,

I think I've read almost every post you've written over the last few years in the last few days, hoping you'd already created something I need, but so far no success.

I'm trying to find a tool that can export up to 100-200 different daily bars for different markets (for each, I need daily bars for the last 2 days), with OHLC and particular EMA's and ATR's numbers in a separate column next to each. Does your tool above do this? I'm a bit of a newb - learning this all from scratch, so instructions would be hugely appreciated on how to install/use/customise too.

M
  • Post #18
  • Quote
  • May 27, 2015 2:07pm May 27, 2015 2:07pm
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,081 Posts
Quoting mfunk
Disliked
I'm trying to find a tool that can export up to 100-200 different daily bars for different markets (for each, I need daily bars for the last 2 days), with OHLC and particular EMA's and ATR's numbers in a separate column next to each. Does your tool above do this?
Ignored
Sorry, no it doesn't. It's not possible to anticipate which indicators (EMAs, ATRs, or the millions of others) that each individual will use, hence I limited the indicator to outputting OHLCV only.

I've attached the source code, on the off chance that you can find a programmer who can recode it to run in MT4 build 600 onward (the attached .mq4 compiles with 123 errors and 18 warnings in build 745), and then add your requested modifications. The code libraries that it uses can be found in this thread (many thanks to pips4life for upgrading them).
Attached File
File Type: mq4 Output History.mq4   6 KB | 1,462 download
  • Post #19
  • Quote
  • Mar 23, 2016 7:50pm Mar 23, 2016 7:50pm
  •  sunyc1982
  • | Joined Aug 2009 | Status: Member | 7 Posts
hanover,you you just like a god.
  • Post #20
  • Quote
  • Mar 25, 2016 7:50pm Mar 25, 2016 7:50pm
  •  cyber1
  • Joined Jan 2011 | Status: Member | 1,299 Posts
Quoting mfunk
Disliked
Hi Hanover, I think I've read almost every post you've written over the last few years in the last few days, hoping you'd already created something I need, but so far no success. I'm trying to find a tool that can export up to 100-200 different daily bars for different markets (for each, I need daily bars for the last 2 days), with OHLC and particular EMA's and ATR's numbers in a separate column next to each. Does your tool above do this? I'm a bit of a newb - learning this all from scratch, so instructions would be hugely appreciated on how to...
Ignored
mfunk-
Try this one. it has several indicators already set up.
Attached File
File Type: mq4 FXPT_ExportHistoryCSV.mq4   6 KB | 1,968 download
1
  • Platform Tech
  • /
  • Data export to CSV
  • Reply to Thread
    • Page 1 2
    • Page 1 2
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021