sHistoryExport - Convenient script for exporting historical data in МetaТrader 4 format - Script for MetaTrader 5





Historical data export script.
Problems with history in MetaTrader 4? Load detailed history of any depth from MetaTrader 5!
Load the script in "terminal_data_folder\MQL5\scripts\".
Load library viewing history and string into "terminal_data_folder\MQL5\Include\komposter\".
Compile the script.
Step 2: Set History Depth
Go to the menu "Tools - Options" (Ctr+O) or specify the number of bars to export ("Maximum number of bars in window") on the "Chart" tab. The annual history of М1 is about 370 000 columns.

Click "ОК" and restart МТ.
Step 3: Set up the instrument list
If you want to load the history of multiple parameters at once, add them to Market Watch and hide unnecessary tools:

Step 4: Run the script
Drag the script to any chart and set external variable values:

Click "ОК" and wait for the shutdown message. You can track your progress on the "Expert Advisor" tab of the terminal:
2013.03.28 11:42:55 sHistoryExport(EURUSD, H1) GBPJPY, PERIOD_M1: Sync history in 1.5 seconds
2013.03.28 11:43:25 sHistoryExport(EURUSD, H1) GBPJPY, PERIOD_M1: 1,100,000 bars were written to "History" (MetaQuotes-Demo)\GBPJPYM1.csv" and "History (MetaQuotes-Demo)\GBPJPY1.hst" in 30.0 seconds!
2013.03.28 11:43:27 sHistoryExport(EURUSD, H1) EURJPY, PERIOD_M1: History synced in 1.6 seconds
2013.03.28 11:43:55 sHistoryExport(EURUSD, H1) EURJPY, PERIOD_M1: 1,100,000 bars were written to "History" (MetaQuotes-Demo)\EURJPYM1.csv" and "History (MetaQuotes-Demo)\EURJPY1.hst" in 28.6 seconds!
2013.03.28 11:43:57 sHistoryExport(EURUSD, H1) NZDUSD, PERIOD_M1: History synced in 1.6 seconds
2013.03.28 11:44:26 sHistoryExport(EURUSD, H1) NZD/USD, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\NZDUSD1.csv" and "History (MetaQuotes-Demo)\NZDUSD1.hst" in 29.0 seconds!
2013.03.28 11:44:28 sHistoryExport(EURUSD, H1) AUDUSD, PERIOD_M1: History synced in 1.7 seconds
2013.03.28 11:44:56 sHistoryExport(EURUSD, H1) AUD/USD, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\AUDUSDM1.csv" and "History (MetaQuotes-Demo)\AUDUSD1.hst" in 28.2 seconds!
2013.03.28 11:44:59 sHistoryExport(EURUSD, H1) USDCAD, PERIOD_M1: History synced in 1.8 seconds
2013.03.28 11:45:27 sHistoryExport(EURUSD, H1) USD/CAD, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\USDCADM1.csv" and "History (MetaQuotes-Demo)\USDCAD1.hst" in 28.3 seconds!
2013.03.28 11:45:31 sHistoryExport(EURUSD, H1) USDCHF, PERIOD_M1: History synced in 3.9 seconds
2013.03.28 11:46:00 sHistoryExport(EURUSD, H1) USDCHF, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\USDCHF1.csv" and "History (MetaQuotes-Demo)\USDCHF1.hst" in 28.5 seconds!
2013.03.28 11:46:01 sHistoryExport(EURUSD, H1) GBPUSD, PERIOD_M1: History synchronized in 1.5 seconds
2013.03.28 11:46:31 sHistoryExport(EURUSD, H1) GBP/USD, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\GBPUSD1.csv" and "History (MetaQuotes-Demo)\GBPUSD1.hst" in 29.5 seconds!
2013.03.28 11:46:33 sHistoryExport(EURUSD, H1) USDJPY, PERIOD_M1: History synced in 2.6 seconds
2013.03.28 11:47:03 sHistoryExport(EURUSD, H1) USDJPY, PERIOD_M1: 1,100,000 bars were written to "History" (MetaQuotes-Demo)\USDJPYM1.csv" and "History (MetaQuotes-Demo)\USDJPY1.hst" in 29.4 seconds!
2013.03.28 11:47:04 sHistoryExport(EURUSD, H1) EURUSD, PERIOD_M1: History synchronized in 1.5 seconds
2013.03.28 11:47:33 sHistoryExport(EURUSD, H1) EURUSD, PERIOD_M1: 1,100,000 bars were written to "History (MetaQuotes-Demo)\EURUSDM1.csv" and "History (MetaQuotes-Demo)\EURUSD1.hst" in 28.8 seconds!
2013.03.28 11:47:33 sHistoryExport(EURUSD, H1) History export completed in 279.6 seconds! 9 files have been written:
2013.03.28 11:47:33 sHistoryExport(EURUSD, H1) D:\_Forex\MetaTrader 5 Work\MQL5\Files\History (MetaQuotes-Demo)\
If you set a higher number of instruments and/or timeframes and/or loaded bars, the script can work very long or generally hang due to insufficient core memory! Fully assess the potential of your hardware.
After loading all necessary history, the script will display a window with information and exit. The name of the folder where the file is stored, you can copy it directly from the alert window:

csv file, written by a script, prepared for import into MetaTrader 4 ("Quote Archive - Import"):

history of change
Attachment download
📎 historyexport.mq5 (5.88 KB)
Source: MQL5 #1252
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •