Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | Save OHLCV Data from Chart to CSV File

The standard method of getting historical data in metatrader5 is to use "View>Symbols>Request" tool as shown in the picture below:

MetaTrader Experts, Indicators, Scripts and Libraries

However, this sometimes doesn't return all the data available on the chart.

This script saves all the available historical data to a CSV file located in "Files" folder inside the "Common Data Path" directory.

Note: Make sure "Max bars in chart" is set to "Unlimited" in 'Tools>Options>Charts' (see the picture below).

MetaTrader Experts, Indicators, Scripts and Libraries

51567