Published Sheet Reader
A published Google Sheet is the simplest way to hand a running EA a live settings table that someone can edit from a phone - no server, no authentication, just File > Share > Publish to web with CSV output selected. The obvious way to read it back, StringSplit(csvText, ','), works right up until a cell contains a comma of its own - a note field like "tight spread, London session" - at which point the naive split cuts that one cell into two and every column after it shifts one to the left, silently corrupting the row rather than failing loudly. This header parses CSV the way the format actually works: a field wrapped in double quotes can contain commas (and newlines, though see the limitation below), and a doubled quote "" inside a quoted field is the escape for one literal quote character - the standard RFC-4180 shape that Google Sheets, Excel and every other spreadsheet CSV export produce. PublishedSheetParseCsv builds a rectangular grid from the result, padding short rows with empty cells, so calling code can read PublishedSheetGetCell(cells, colCount, row, col) without ever range- checking a ragged row by hand. PublishedSheetFetch/PublishedSheetFetchAndParse wrap WebRequest with the same not-whitelisted detection every network call in this catalogue needs - a published-sheet URL fails exactly like any other WebRequest target the first time it is not on the terminal's allow-list, and PublishedSheetErrorDescription spells out the fix instead of leaving a bare -1. Notes and limitations - Quoted fields may NOT contain an embedded newline. The document is split into lines before any quote parsing happens, so a cell with a line break inside it (Sheets allows this with Alt+Enter) will be cut at the wrong point. Keep multi-line notes out of a sheet meant to be read by this header. - A row wider than maxCols (default 64) has its extra trailing cells silently dropped - raise maxCols if a sheet genuinely needs more columns than that. - WebRequest only reaches the network when the URL's domain is on the terminal's allow-list, and that list is per terminal installation - every machine this is downloaded to needs the one-time setup. - No caching, no polling loop and no change detection - this is a single fetch-and-parse call; build any "re-read every N minutes" logic in the calling EA/script around it. - The response is read as UTF-8. A sheet published with non-UTF-8 text will come back mis-decoded.
Script · MT4 · v1.0 · Free
About Published Sheet Reader
Published Sheet Reader is a script for MetaTrader 4. It is set up for gold (XAUUSD). It has 1 setting, such as Test url. MQL source code included.
Files in the download: PublishedSheetReader.mqh, PublishedSheetReader.txt, PublishedSheetReaderDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Test url | https://docs.google.com/spreadsheets/d/e | Published-sheet CSV URL to try live (needs whitelisting) |
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: Trading Sessions · Risk & Lot Size · Gold (XAUUSD) · MT4 Script · MQL4 Source Code