# 📊 Crystal Data Extractor — MT5 **By Crystal AI Systems** | [MQL5 Profile](https://www.mql5.com/en/users/jawadtrader22) Export **Tick** or **OHLC** market data to a clean comma-separated CSV file — directly from MetaTrader 5. --- ## ✅ Features - Two modes: **Tick Data** (Bid/Ask/Last) or **OHLC Bars** (Open/High/Low/Close/Volume/Spread) - Works on **live charts** AND **Strategy Tester** - Proper CSV format — opens correctly in **Excel** (no column merging) - Historical OHLC dump on startup (configurable lookback) - Auto-named files with symbol + timeframe - Optional file prefix for organizing multiple runs --- ## 📁 File Locations ### Live Chart: ``` File > Open Data Folder > MQL5 > Files > XAUUSD_M15_OHLC.csv ``` ### Strategy Tester: ``` File > Open Data Folder > Tester > [AgentID] > Agent-127.0.0.1-3000 > MQL5 > Files ``` > ⚠️ Tester files are NOT in the main MQL5\Files folder! --- ## ⚙️ Input Parameters | Parameter | Description | |-----------|-------------| | Data Mode | TICK = raw tick data / OHLC = closed candle bars | | Timeframe | Used in OHLC mode only | | Lookback Bars | Historical bars dumped on startup (0 = disabled) | | File Prefix | Optional label added to filename | --- ## 📄 CSV Columns **Tick mode:** `Time, Bid, Ask, Last, TickCount` **OHLC mode:** `Time, Open, High, Low, Close, Volume, Spread` --- ## 🚀 How to Use 1. Copy `Crystal_DataExtractor.mq5` to your MT5 `MQL5\Experts\` folder 2. Compile in MetaEditor (F7) 3. Attach to any chart (e.g. XAUUSD M1) 4. Set your preferred **Data Mode** and **Timeframe** in Inputs 5. CSV file is created automatically in `MQL5\Files\` ### Strategy Tester Tip: > Set the Tester chart TF **lower** than your OHLC input TF. > Example: Want H1 OHLC? Run tester on M1 or M5. > Use **"Every tick"** model for best accuracy. --- ## 📂 File Naming | Mode | Filename | |------|----------| | OHLC | `XAUUSD_M15_OHLC.csv` | | Tick | `XAUUSD_Ticks.csv` | | With prefix | `Test1_XAUUSD_M15_OHLC.csv` | --- ## 📜 License Free to use and modify. Credit appreciated. © Crystal AI Systems — [jawadtrader22](https://www.mql5.com/en/users/jawadtrader22)