Export Indicator Buffer To CSV
Pulling the numbers out of a custom indicator you did not write, to check its values against a spreadsheet model or feed them into something else, normally means opening the indicator's source and adding an export routine by hand. This script does it from the outside: point it at any compiled indicator by name, tell it which buffer and how many bars, and it writes one CSV row per bar without touching the indicator's source at all. The honest limitation is what iCustom() can and cannot pass through. It only accepts a fixed, positional list of parameters, and this script offers eight of them, every one a double. If the target indicator's own inputs are all numeric, in the same order, this works perfectly. If any of them is a string or a whole number the indicator specifically expects as an int rather than a double, or if it declares more than eight inputs, this script cannot reach it - not because of a shortcut taken here, but because iCustom() genuinely has no generic way to pass a typed argument list, and a bridge like this one can only offer the one type that covers the common case. Buffer cells the indicator has deliberately left blank come back from the platform as EMPTY_VALUE, a sentinel around 1.7 times ten to the 308th power. Writing that number into a CSV cell makes every downstream average, chart and formula wrong in a way that is easy to miss until it has already cost time. This script checks for the sentinel and writes an empty cell instead. Notes and limitations - Only double-typed indicator inputs are reachable. String and int inputs, and a ninth parameter or beyond, are not - see the full description. - Requesting more bars than exist in the terminal's history, or more than the indicator has calculated, exports what is available and says so in the log; nothing is padded. - Values are written with eight decimal places on both platforms, since a generic export cannot know whether the buffer holds a price, a percentage or something else entirely. - An indicator that repaints will export whatever value it held at the moment this script ran, which is not necessarily the value it will hold later for the same bar - that is a property of the indicator, not of this exporter.
Script · MT4 · v1.0 · Free
About Export Indicator Buffer To CSV
Export Indicator Buffer To CSV is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 14 settings, such as Indicator name, Buffer index and Symbol. MQL source code included.
Files in the download: ExportIndicatorBuffer.ex4, ExportIndicatorBuffer.mq4, ExportIndicatorBuffer.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Indicator name | Indicator name (subfolders: Examples\\MyIndicator) | |
| Buffer index | 0 | Buffer index to read (the "mode" argument of iCustom) |
| Symbol | Symbol ("" = this chart's symbol) | |
| Timeframe | PERIOD_CURRENT | Timeframe |
| Bar count | 500 | Bars to sample, most recent first |
| Param1 | 0.0 | Indicator input 1 (positional double, unused ones ignored) |
| Param2 | 0.0 | Indicator input 2 |
| Param3 | 0.0 | Indicator input 3 |
| Param4 | 0.0 | Indicator input 4 |
| Param5 | 0.0 | Indicator input 5 |
| Param6 | 0.0 | Indicator input 6 |
| Param7 | 0.0 | Indicator input 7 |
| Param8 | 0.0 | Indicator input 8 |
| Delimiter | DelimiterComma | CSV column separator |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code