Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Export candles and indicators data to external csv file - script for MetaTrader 5

Views:
31
Published:
Updated:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

ExportDataToCSV is a lightweight and customizable MQL5 script designed to export historical price action data (OHLCV) and popular technical indicators directly to a .csv file.

Unlike static exporters that dump unnecessary data, this script uses dynamic handle initialization. It only creates indicator handles, waits for calculations, and writes columns for the specific parameters you enable in the input window—saving processing time and keeping your datasets clean for Excel, Python (Pandas/NumPy), R, or Machine Learning models.


Key Features:

  • Selective Export (Checkboxes): Choose exact data columns to include via boolean inputs (true /false ).

  • Resource Efficient: Only initializes and calculates indicators that are explicitly selected by the user.

  • Built-in Synchronization: Includes a safe waiting loop (BarsCalculated ) to ensure all selected indicator buffers are completely calculated before writing to the file.

  • Clean CSV Formatting: Automatically generates dynamic headers matching your selected inputs, along with formatted timestamps (YYYY.MM.DD HH:MM ).

Available Data & Indicators:

  • Timestamp: Bar date and time (exported by default under the column Date_Time ).

  • Price Action: Open, High, Low, Close (OHLC).

  • Volume: Tick Volume.

  • Volatility & Trend:

    • ATR (14)

    • ADX (14) — exports Main, +DI, and -DI buffers

  • Momentum & Oscillators:

    • RSI (7) and RSI (14)

    • MACD (12, 26, 9) — exports Main and Signal lines

    • Stochastic (5, 3, 3) — exports Main and Signal lines

    • CCI (14)

    • Momentum (14)

    • MFI (14)

Input Parameters:

  • General Settings:

    • InpCandles : Number of historical bars to export (default: 1000 ).

    • InpFileName : Output file name (default: "MT5Export.csv" ).

  • Data to Export: Individual true /false toggles for OHLC, Tick Volume, and each of the 9 technical indicators.

How to Use & Where to Find the File:

  1. Attach the script to any chart with your desired symbol and timeframe.

  2. Check the boxes for the data/indicators you want to export and set the number of candles.

  3. Click OK and check the Experts tab in the Terminal for the confirmation message.

  4. Retrieve your CSV file in MetaTrader 5 via: File -> Open Data Folder -> MQL5 -> Files.

Net Currency Exposure and Hedged Margin Simulator Panel Net Currency Exposure and Hedged Margin Simulator Panel

A real-time CCanvas on-chart utility for MetaTrader 5 that calculates net lot exposure per currency across all open positions and simulates the exact margin, Margin Level (%), and Stop-Out buffer impact of a new Buy or Sell order—automatically accounting for your broker's hedged margin rules.

Prop Firm Daily Loss and Drawdown Monitor Prop Firm Daily Loss and Drawdown Monitor

Free panel indicator for funded / prop-firm accounts: shows the room left before the daily loss limit and the static maximum drawdown, and alerts when you get close. Monitor only: it never opens, closes or blocks trades.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.