Purpose & User Intent: The tool solves the problem of migrating and validating trading automation code between MQL4 and MQL5. It targets professional developers, quant researchers, and algo-traders who maintain Expert Advisors, indicators, or scripts and need reliable syntax updates, API mapping, and compatibility checks when upgrading to MQL5 or backporting to MQL4. Typical use occurs during platform upgrades, developer refactoring sessions, or rapid prototyping of migration strategies.\n\nCore Logic & Features: The tool uses a rule-based migration engine with optional heuristics. Required features include input code parsing, detection of language differences, transformation rules for common MQL4 constructs (OnTick handling, order functions, event handlers, object handling) and generation of migrated code. Optional/advanced features include batch processing, migration profiles, detailed compatibility reports, and diff-style output. The tool outputs migrated code plus a report of changes and remaining gaps.\n\nInputs & Outputs: Inputs include: source_code (string, required), source_version (enum MQL4|MQL5, required), target_version (enum MQL4|MQL5, required, default MQL5), options (object with strict_syntax boolean, include_diffs boolean). Outputs include: converted_code (string), compatibility_report (string or structured JSON), migration_notes (string). Sample: source_code contains an OnTick() implementation; converted_code contains updated event handlers; report lists function mappings.\n\nAlgorithms & Calculations: The converter applies a set of transformation rules, including function signature changes, API calls, and event-driven semantics. It uses lexical analysis, pattern matching, and context-aware rewrites. Examples: map OrderSend to appropriate trade functions in MQL5; translate iBars and iClose calls; adjust data types and structures to MQL5 classes where applicable. All logic is rule-based with fallback hand-off for ambiguous cases.\n\nError & Edge Cases: If input is empty or exceeds size limits, the tool returns an error with guidance. If code references non-supported libraries, it flags them and suggests alternatives. Missing version hints trigger validation warnings. Large batch jobs may require multi-step processing and partial results.\n\nIndustry/Region & Localization: The tool follows MQL5/MQL4 standards used by the global retail and institutional trading community. No locale-sensitive data is required; all code and messages use English technical terms. Localization is limited to language display of reports if enabled.\n\nAssumptions & Exclusions: Assumes input is valid MQL4 or MQL5 source code. Not a compiler; cannot guarantee complete functional parity across all codebases. Excludes non-code assets, external libraries beyond standard API mappings, and graphical object migration.