Skip to content

About

CSV-driven MT4 execution bridge with runtime risk, PM commands, ADD/REDUCE/EXIT control, and Python integration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SignalFileTrader PRO for MetaTrader 4

SignalFileTrader PRO is a proprietary MetaTrader 4 execution-side Expert Advisor designed for file-driven trading workflows, Python-to-MT4 command processing, protected position management, runtime risk control, and operator-facing chart supervision.

The system acts as the MT4 terminal execution layer inside a larger quantitative trading stack. It reads structured trade signals from CSV files, applies local execution and risk filters, manages broker orders, processes external portfolio-management commands, exports position snapshots for Python-side analytics, and exposes multiple on-chart control panels for live operational control.

Status: Portfolio / evaluation repository
Platform: MetaTrader 4 / MQL4
Repository type: Public documentation and screenshots for a proprietary trading-system component
Core role: MT4-side execution, confirmation, risk, ADD, REDUCE, EXIT, and bridge controller


Table of Contents


Overview

SignalFileTrader PRO for MetaTrader 4 is not a simple signal-reader EA. It is a terminal-side execution controller built to connect external research and decision systems with MT4 broker execution.

The EA is designed around a file-mediated architecture where a Python-side system can generate entry signals, request portfolio-management actions, inspect live MT4 positions, receive bridge status, request history exports, and coordinate ADD / REDUCE / EXIT decisions through structured CSV files.

At runtime, the EA combines:

  • CSV-based signal ingestion;
  • MT4 order execution;
  • rule-based risk sizing;
  • ATR-based stop and safety logic;
  • local live-chart confirmation before entry;
  • Python command processing;
  • ADD / pyramiding governance;
  • protected common-stop handling;
  • position snapshot export;
  • bridge heartbeat and status files;
  • structured risk / trade / operation logging;
  • on-chart configuration pages for live operational control.

The project is intended to demonstrate how a proprietary Python-assisted trading stack can use MetaTrader 4 as an execution endpoint while keeping analytics, ranking, confirmation, risk policy, and portfolio logic modular.


What This Project Demonstrates

This repository showcases a professional MT4-side execution component with emphasis on practical trading infrastructure rather than isolated indicator logic.

Key areas demonstrated:

  • Python-to-MT4 execution bridge using CSV input, output, acknowledgement, status, and snapshot files.
  • Signal-file execution from external ranking or analytics engines.
  • Runtime risk enforcement including ATR-based stops, minimum stop protection, slippage-aware risk, commission-aware risk auditing, and min-lot overshoot checks.
  • Live entry confirmation using short-term M1/M5 structure, ATR shock detection, candle body / wick / close-edge behavior, sweep logic, and optional entry-moment trigger.
  • Command-based position management for EXIT, REDUCE, ADD, and reverse workflows.
  • Protected ADD / pyramiding engine with profit-funded sizing, forced lock-before-ADD logic, common-SL protection, margin guards, basket-level risk checks, Python approval lanes, and emergency ADD controls.
  • Runtime UI control through multiple chart panels instead of relying only on static MT4 inputs.
  • Bridge observability through logs, status CSVs, position snapshots, trade-operation logs, and audit files.

V54.280 Runtime Control Layer

The V54.280 build extends the project from a file-driven MT4 executor into a multi-layer runtime execution and safety controller.

Important version-level additions include:

  • AutoTuner preflight snapshot hardening;
  • Python-requested local-time M1 OHLC windows by symbol and timestamp;
  • OHLC request / response / status CSV bridge;
  • optional M1 candle logging for AutoTuner workflows;
  • live chart confirmation panel;
  • entry-moment trigger confirmation;
  • ADD CFG persistence guard;
  • hard ADD OFF latch and CSV hard-disable guard;
  • strict ADD path isolation from generic entry retry paths;
  • ATR + Hybrid confluence lot-boost support with EA-side caps;
  • Market Memory guard for blocking weak or probationary boost states;
  • risk-audit and commission-aware sizing protection;
  • trade retry queues and SL/TP recalculation safety;
  • external pause / kill interlock support;
  • bridge status, history export, position snapshot, and trade-operation diagnostics.

PM CORE CFG

The PM CORE CFG page centralizes the main execution safety, entry-risk, command-rate, retry, and SL/TP recalculation controls.

It contains runtime controls for:

  • hard minimum stop-loss enforcement;
  • ATR-safe entry and trailing behavior;
  • broker min-lot risk overshoot protection;
  • signal quality and confidence filtering;
  • commission-aware entry-risk checking;
  • reduce-percent clamping;
  • command-rate limiting;
  • symbol-level risk caps;
  • pending command expiry;
  • queued retry handling;
  • full entry retry support;
  • automatic SL/TP recalculation for retried entries.

PM Core CFG

PM LC CFG

The PM LC CFG page adds a local live-chart confirmation layer before external Python entry signals are allowed to reach broker execution.

This layer is useful when the upstream model produces a valid signal, but the immediate chart state is too weak, too late, too volatile, or structurally invalid.

It can evaluate:

  • minimum live-confirmation pass score;
  • M1 and M5 ATR shock conditions;
  • structure lookback;
  • breakout buffer;
  • candle body strength;
  • close-edge quality;
  • wick rejection behavior;
  • sweep reversal allowance;
  • opposite breakout blocking;
  • opposite shock-momentum blocking;
  • optional M1/M5 trend agreement;
  • EMA fast / slow alignment;
  • chart marking for blocked confirmations;
  • optional final entry-moment trigger.

PM LC CFG

PM ADD CFG

The PM ADD CFG page manages protected ADD / pyramiding behavior separately from normal entry logic.

The ADD engine is designed to prevent uncontrolled averaging or unsafe expansion by forcing ADD decisions through basket-level safety, common-SL logic, protected-floor checks, Python bridge rules, and margin constraints.

It contains controls for:

  • Python ADD request / approval bridge;
  • direct Python ADD mode;
  • profit-funded ADD sizing;
  • forced lock-before-ADD protection;
  • old ADD path hard blocking;
  • protected floor checks;
  • ADD readiness logging;
  • emergency ADD lane controls;
  • basket ATR and add-distance rules;
  • post-ADD common-SL enforcement;
  • maximum pyramid level;
  • maximum single-lot and basket-lot caps;
  • margin-use and free-margin constraints;
  • request cooldown and throttling;
  • emergency confidence, score, age, and risk filters.

PM ADD CFG

Together, these three pages turn the EA into a configurable MT4-side execution, confirmation, risk, command, and position-expansion controller for a larger Python-assisted trading architecture.


Screenshots

Main on-chart control panel

Primary operator interface with execution controls, trade-management settings, risk limits, safety toggles, and PM state.

Main Panel

Light theme panel

Alternative light-theme view of the main execution and management controls.

Light Theme Panel

PM control with REDUCE enabled

PM panel exposing automated and manual control over EXIT, ADD, and REDUCE behavior.

PM Reduce Panel

Runtime dashboard and signal monitor

Runtime overview showing spread, daily drawdown, position count, day PnL, recent signal state, and execution context.

Runtime Dashboard

Compact runtime monitor

Focused lower-panel view for live signal and position monitoring.

Compact Monitor

Bridge scan and command diagnostics

MT4 Experts log showing bridge scanning, command parsing, and external command execution flow.

Bridge Scan

ADD command activity

Journal output demonstrating ADD-related command handling and bridge-side coordination.

ADD Command Log

REDUCE command activity

Journal output demonstrating partial reduction handling from external PM commands.

Reduce Command Log

Risk micro-panel

Compact risk and PnL summary panel for operator review.

Risk Panel


Architecture

SignalFileTrader PRO is intended to run as the MT4 execution endpoint of a broader trading-system architecture.

Python research / model / ranking engine
        |
        |  TradePicker_Entries.csv
        v
MetaTrader 4 / SignalFileTrader PRO
        |
        |  broker orders, SL/TP, management, ADD/REDUCE/EXIT
        v
Broker execution layer
        |
        |  PM_Positions.csv, MT4_Bridge_Status.csv, trade logs, audits
        v
Python portfolio manager / monitor / AutoTuner

The design separates:

  • signal generation from broker execution;
  • portfolio-management decisions from terminal-side order handling;
  • model output from local execution safety;
  • research logic from MT4-specific trade operations.

This separation makes the workflow easier to inspect, test, debug, and evolve.


Execution Workflow

A typical runtime cycle is:

  1. A Python-side signal, ranking, or portfolio tool writes a structured entry row to TradePicker_Entries.csv.
  2. The EA scans the file inside the MT4 MQL4/Files area.
  3. The EA parses symbol, direction, timestamp, score, confidence, and optional signal metadata.
  4. Local entry checks validate signal age, timestamp quality, duplicate processing, spread, cooldown, daily loss, max positions, confidence, score, ATR availability, and risk conditions.
  5. Optional live-chart confirmation evaluates M1/M5 short-term behavior before allowing execution.
  6. If the signal passes, the EA calculates lot size, SL, TP, slippage buffer, commission-adjusted risk, and broker constraints.
  7. The EA sends the order or queues a retry if a transient trade operation error occurs.
  8. Open positions are managed using trailing, break-even, partial close, ATR stop, and safety rules.
  9. Python-side PM commands can request EXIT, REDUCE, ADD, EXIT_AND_REVERSE, or history/snapshot operations.
  10. The EA writes bridge status, logs, audit files, trade operation diagnostics, and live position snapshots back to CSV.

Core Capabilities

Signal-file entry execution

  • Reads external entry signals from CSV.
  • Supports symbol-aware execution routing.
  • Validates signal freshness and timestamp quality.
  • Prevents duplicate signal processing.
  • Applies score and confidence gates.
  • Supports confidence-based risk scaling.
  • Supports ATR + Hybrid confluence lot-boost tags with EA-side caps.
  • Blocks unsafe boost states using Hybrid Anchor and Market Memory guards.

Risk and sizing

  • Fixed-lot and risk-percent sizing paths.
  • ATR-based stop-loss calculation.
  • Fixed-pip fallback control.
  • Hard fail if ATR/history is unavailable when configured.
  • Minimum stop-loss protection.
  • Broker min-lot risk overshoot protection.
  • Slippage-buffer inclusion in risk calculation.
  • Commission-aware risk auditing.
  • Per-symbol risk cap option.
  • Gradient risk reduction by drawdown.
  • Daily loss and position-limit controls.

Trade management

  • Stop-loss and take-profit placement.
  • ATR-linked stop behavior.
  • Trailing-stop logic.
  • Break-even handling.
  • Partial close / staged de-risking support.
  • Reverse and deferred reverse-open handling.
  • Queued retry support for transient send / close / modify errors.
  • SL/TP recalculation support for queued entry retries.

PM command handling

  • Reads external commands from TradePicker_Commands.csv.
  • Processes portfolio commands such as EXIT, REDUCE, ADD, and EXIT_AND_REVERSE.
  • Applies command-age limits, cooldowns, repeat guards, and rate controls.
  • Preserves pending commands when rate or cooldown conditions temporarily block execution.
  • Supports separate handling rules for urgent exits/reductions.
  • Logs command execution state and diagnostics.

Bridge and observability

  • Exports live position snapshots.
  • Writes MT4 heartbeat / bridge status.
  • Supports external pause and kill-switch files.
  • Supports closed-history export for Python review.
  • Writes structured trade logs and operation logs.
  • Writes entry-risk audit and profile-lineage audit files.

Python Bridge and CSV Interfaces

The EA communicates with external tools through a set of CSV and control files. Exact schemas may vary by deployment, but the core bridge lanes are:

File Direction Purpose
TradePicker_Entries.csv Python → MT4 Entry signal input file.
TradePicker_Commands.csv Python → MT4 PM command file for EXIT, REDUCE, ADD, reverse, and bridge operations.
TradePicker_Entries_Done.csv MT4 → Python Processed entry rows / entry completion tracking.
PM_Add_Settings.csv Python / config → MT4 Optional ADD settings mirror for runtime ADD behavior.
PM_AddRequests.csv MT4 → Python EA-generated ADD approval requests.
PM_AddApprovals.csv Python → MT4 Python-approved ADD decisions.
PM_AddReadiness.csv MT4 → Python ADD readiness diagnostics.
PM_Positions.csv MT4 → Python Live open-position snapshot export.
PM_ClosedTrades.csv MT4 → Python Closed-trade history export.
MT4_Bridge_Status.csv MT4 → Python Heartbeat / terminal-side status reporting.
SFT_AutoTuner_OHLC_Request.csv Python → MT4 On-demand local-time OHLC window request.
SFT_AutoTuner_OHLC_Response.csv MT4 → Python OHLC response rows.
SFT_AutoTuner_OHLC_Status.csv MT4 → Python OHLC bridge status and diagnostics.
SFT_AutoTuner_M1_Candles.csv MT4 → Python Optional continuous closed-M1 candle log.
SFT_EntryRiskAudit.csv MT4 → Python / audit Entry-risk calculation breakdown.
SFT_ProfileOrderLineage_V54_213.csv MT4 → Python / audit Ticket-to-profile / signal lineage tracking.
SignalFileTrader_TradesLog.csv MT4 → audit Structured trade lifecycle log.
SFT_TradeOps.csv MT4 → audit Trade queue / retry / operation diagnostics.
STAGE25_PAUSE.txt External control → MT4 External pause interlock.
STAGE25_KILL_SWITCH.txt External control → MT4 External kill-switch interlock.

This bridge design allows Python-side systems to remain responsible for analytics and portfolio decisions while the EA remains responsible for broker execution, local validation, and trade-operation safety.


Risk, Confirmation, and Safety Logic

SignalFileTrader PRO contains several independent safety layers.

Entry signal filters

  • Minimum score gate.
  • Minimum confidence gate.
  • Signal-age filter.
  • Future timestamp skew protection.
  • Parsable timestamp requirement.
  • Duplicate signal ID protection.
  • Optional no-trade row marking to prevent rejected rows from re-firing after restart.

ATR and stop protection

  • ATR-based SL calculation.
  • Explicit ATR timeframe support.
  • Helper chart preload for missing symbol/timeframe history.
  • Abort-if-ATR-not-ready behavior.
  • Hard minimum stop-loss protection.
  • SL/TP recalculation for retried entries.

Risk audit

  • Commission-aware risk calculation.
  • Auto-learning commission estimate from closed history.
  • Exact-symbol and similar-symbol fallback sampling.
  • Slippage buffer in risk calculation.
  • Hard-fail option if risk calculation is unsafe.
  • Structured risk audit CSV output.

Live chart confirmation

The live confirmation layer is intentionally local to the MT4 terminal. It acts as a final market-state gate after the external signal is received.

It can block entries when:

  • the chart is in an ATR shock state;
  • the current structure contradicts the signal;
  • an opposite breakout appears;
  • momentum is moving aggressively against the proposed entry;
  • candle body / close-edge / wick quality is insufficient;
  • optional trend agreement is missing;
  • the final entry-moment candle does not confirm the direction.

This creates a separation between model signal validity and immediate execution quality.


ADD / Pyramiding Engine

The ADD engine is one of the most important parts of the project. It is designed around controlled position expansion rather than unguarded averaging or martingale behavior.

Main ADD principles:

  • Old unsafe ADD paths are hard-blocked.
  • ADD is isolated from generic delayed entry and retry paths.
  • Existing same-direction baskets can be forced through strict ADD / common-SL logic.
  • Python can participate through request / approval / direct-add bridge lanes.
  • The EA still owns terminal-side safety checks.
  • ADD can be restricted to profit-funded risk budgets.
  • The basket can be forced into a protected common SL before expansion.
  • ADD is blocked if the projected floor, stop distance, margin, basket lots, or risk budget is unsafe.

ADD controls include

  • maximum pyramid levels;
  • minimum ADD distance in ATR;
  • minimum basket profit in ATR;
  • post-ADD common-stop enforcement;
  • minimum post-ADD SL distance;
  • spread-noise buffer checks;
  • protected floor money / equity / initial-risk controls;
  • minimum locked profit requirements;
  • locked-profit usage percentage;
  • ADD risk safety buffer;
  • maximum ADD risk as percentage of initial risk;
  • maximum single ADD lot;
  • maximum total basket lots;
  • maximum margin use after ADD;
  • minimum free margin after ADD;
  • ADD request cooldown;
  • ADD approval scan interval;
  • optional emergency ADD path with confidence, score, age, and loss controls.

The goal is to support structured scaling only when the basket state, risk budget, and execution context allow it.


AutoTuner and OHLC Bridge

The V54.280 build adds an AutoTuner-oriented OHLC bridge that lets Python request local-time M1 candle windows from the EA.

This is useful when Python-side tuning or preflight logic needs candles aligned with the same local timestamp context used by the terminal.

Supported concepts:

  • optional continuous M1 candle logging;
  • on-demand OHLC request bridge;
  • local-time timestamp alignment;
  • multi-symbol request handling;
  • request cap per timer cycle;
  • configurable bars-before and bars-after windows;
  • response and status files for diagnostics.

This turns the EA into both an execution endpoint and a data-response endpoint for selected terminal-side market context.


Runtime UI Panels

The EA includes multiple chart-side panels so that operational behavior can be monitored and adjusted without recompilation.

Visible panel groups include:

  • main execution panel;
  • PM control panel;
  • PM CORE CFG;
  • PM LC CFG;
  • PM ADD CFG;
  • runtime dashboard;
  • compact monitor;
  • risk micro-panel;
  • statistics / trade-plot controls;
  • minimize / restore controls;
  • dark and light theme support.

This makes the EA practical for supervised live testing because the operator can inspect current state, toggle policy lanes, observe PM commands, and review key runtime values directly on the MT4 chart.


Logging and Diagnostics

The project emphasizes observability because file-bridged systems must clearly show whether a signal or command was received, rejected, delayed, or executed.

Representative diagnostics include:

  • EA initialization logs;
  • watched file announcements;
  • latest signal parsing;
  • signal age / timestamp validation;
  • order execution status;
  • command scan / parse logs;
  • EXIT, REDUCE, ADD, and reverse command traces;
  • pending command status;
  • retry queue status;
  • risk audit file output;
  • trade operation file output;
  • bridge heartbeat output;
  • position snapshot output;
  • ADD readiness output;
  • AutoTuner OHLC response status.

These logs help separate common failure cases such as:

  • no signal file present;
  • signal parsed but blocked by quality filters;
  • ATR or history not ready;
  • risk calculation failure;
  • command too old;
  • command rate-limited;
  • symbol cooldown active;
  • ADD blocked by common-SL or floor protection;
  • broker trade operation failed but queued for retry.

Repository Structure

Suggested public portfolio structure:

SignalFileTrader-PRO-for-MetaTrader/
├── README.md
├── LICENSE
├── .gitignore
└── docs/
    └── screenshots/
        ├── pm-core-cfg.png
        ├── pm-lc-cfg.png
        ├── pm-add-cfg.png
        ├── main-panel-dark.png
        ├── main-panel-light.png
        ├── pm-reduce-panel.png
        ├── runtime-dashboard.png
        ├── compact-monitor.png
        ├── journal-bridge-scan.png
        ├── journal-add-commands.png
        ├── journal-reduce-commands.png
        └── risk-micro-panel.png

Optional private or extended structure for internal use:

mql4/
└── Experts/
    └── SignalFileTrader.mq4

docs/
├── architecture.md
├── command-bridge.md
├── csv-schemas/
│   ├── TradePicker_Entries.md
│   ├── TradePicker_Commands.md
│   ├── PM_Positions.md
│   ├── PM_AddRequests.md
│   ├── PM_AddApprovals.md
│   └── AutoTuner_OHLC.md
└── screenshots/

The public version may intentionally exclude proprietary source code, broker-specific settings, production logs, private CSV samples, and deployment credentials.


Public Demo

A portfolio-safe, clean-room demonstration of the SignalFileTrader PRO operator interface is available in the demo/ directory.

The demo presents synthetic file-driven workflow states, risk previews, position-management controls, and public-safe views corresponding to PM Control, PM CORE CFG, PM LC CFG, and PM ADD CFG.

It does not read or write CSV files, connect to Python or MetaTrader execution services, access trading accounts, calculate production risk or confirmation rules, submit broker orders, or include proprietary runtime logic.

View public demo documentation

SignalFileTrader PRO Public Demo


Repository Note

This repository is published for portfolio, architecture review, and technical evaluation purposes.

It documents a proprietary Expert Advisor and its role inside a larger algorithmic trading infrastructure. Private strategy rules, production deployment details, broker-specific configuration, account identifiers, credentials, and sensitive datasets are intentionally excluded.

The screenshots and documentation focus on the system design, execution bridge, runtime control model, risk-management workflow, and MT4-side integration architecture.


License

This repository is proprietary and publicly viewable for evaluation purposes only.

See the LICENSE file for full terms.


Author

Maintained by Hamid Haddadian
GitHub: @smcalgotrading

About

CSV-driven MT4 execution bridge with runtime risk, PM commands, ADD/REDUCE/EXIT control, and Python integration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors