Loading…

Spreadsheet Driven Trader

Trading off a remote document is dangerous if taken at face value - a stale fetch, a typo'd lot size, or a sheet nobody has touched in three days must never translate into a silent oversized order. This EA requires the sheet to publish its own "updated_at" cell in row 1, and a fetch whose declared age exceeds InpMaxDataAgeMinutes causes the ENTIRE reconciliation pass to be skipped - no opens, no closes, existing positions keep running under their own stops rather than being touched on information nobody can vouch for. This is the same discipline this catalogue's PublishedSheetReader Library assumes a caller will apply; here it is built directly into the trading loop rather than left to whoever calls the header. Every requested lot size is capped locally at InpMaxLotsPerSymbol per symbol and InpMaxTotalLots combined, regardless of what the sheet asks for. At most InpMaxOpensPerCycle new positions open per pass, so a sheet edited to enable every row at once cannot dump the whole book into the market in a single tick. A direction flip (a symbol whose desired side changed from BUY to SELL or back) closes the old position this cycle and only opens the new one on the next pass, so a single reconciliation never both closes and reopens the same symbol - one action per symbol per cycle. CSV parsing (quoted fields, commas inside quotes, the doubled "" escape) is reimplemented self-contained in this file in the same spirit as this catalogue's PublishedSheetReader Library, rather than #include-ing it, since every CodeBase submission must stand alone. Notes and limitations This EA manages at most one position per symbol - it is not a pyramiding tool; a row requesting the same side as an already-open position is left untouched rather than adding to it. It trades on any symbol named in the sheet that the terminal's Market Watch can price, so the sheet itself is the only symbol whitelist - a compromised or mistyped sheet could still direct trading onto an unintended symbol the account happens to have access to, bounded only by the per-symbol and combined lot caps. Stop-loss/take-profit distances are widened to the broker's minimum stop/freeze level automatically rather than rejected outright when the sheet's requested pip distance is too tight.

Expert advisor · MT5 · v1.0 · Free

About Spreadsheet Driven Trader

Spreadsheet Driven Trader is an expert advisor (trading robot) for MetaTrader 5. It has 12 settings, such as Sheet url, Fetch interval sec and Max data age minutes. MQL source code included.

Files in the download: SpreadsheetDrivenTrader.ex5, SpreadsheetDrivenTrader.mq5, SpreadsheetDrivenTrader.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Sheet urlPublished CSV URL (Google Sheets: File > Share > Publish to web > CSV)
Fetch interval sec60Seconds between fetches
Max data age minutes30Sheet's own "updated_at" cell older than this = stale, whole pass skipped
Magic number44300Magic number that tells this EA's orders apart
Max lots per symbol0.10Hard cap - no row may open more than this on one symbol, regardless of request
Max total lots0.50Hard cap on this EA's combined open lots across every symbol
Max opens per cycle2At most this many new positions opened per reconciliation pass
Max spread points40Skip opening if current spread exceeds this many points
Slippage points5Maximum slippage allowed when opening a trade
Dry runfalsetrue = log what would happen, never sends or closes an order
Max retries5
Retry wait ms500

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria