MetaTrader 4 · single-file .mq4

MQL4 AI Coding AgentBuild MT4 EAs, Indicators, and Scripts

Describe your MetaTrader 4 logic in plain English. Review one complete MQL4 artifact, run a single-file MetaEditor syntax check, and keep revising the source before you test it in MT4.

Open the Coding Agent, then choose MQL4 from the language menu.

Pineify MQL4 AI Coding Agent with MQL4 selected, generating a single-file MetaTrader 4 EMA crossover Expert Advisor
One self-contained .mq4 artifact
Official-docs-derived MQL4 context
MetaEditor static diagnostics
Dedicated MQL4 memory

MQL4-specific workflow

Generate code you can inspect, check, and keep editing

Generate One Complete .mq4 File

Describe an Expert Advisor, custom indicator, or utility script. The agent produces one editable MQL4 artifact with the helpers and event handlers kept in the same source file.

  • Expert Advisors with explicit order and risk rules
  • Custom indicators with buffers, plots, and alerts
  • Scripts for bounded one-time terminal tasks

Use MQL4-Specific Reference Context

A versioned reference derived from official MQL4 documentation keeps common signatures, parameter order, event handlers, and classic order APIs separate from MQL5 patterns.

  • MQL4 lifecycle and program-type boundaries
  • Timeseries and built-in indicator calls
  • OrderSelect, OrderSend, and error handling patterns

Inspect MetaEditor Diagnostics

Send the current single-file source to the independent MT4 syntax service. Source-located diagnostics give the agent a concrete next repair instead of a guessed rewrite.

  • MetaEditor compiler diagnostics
  • Line and column locations when available
  • Revision loop inside the same artifact

Keep MQL4 Preferences Separate

Save MQL4-specific naming, risk defaults, and source conventions without mixing them into the memory used for MQL5 or other coding languages.

  • Dedicated MQL4 global memory
  • Continue an existing source artifact
  • Request precise edits in plain English

From an MT4 rule to a testable source file

Generation, source review, static diagnostics, and platform testing are separate gates.

  1. 01

    Select MQL4 and define the program

    Choose MQL4 in the Coding Agent, then state whether you need an Expert Advisor, custom indicator, or script. Include inputs, timeframe, signal, order, and risk rules that must stay explicit.

    Write one MQL4 EA that enters on a closed-bar EMA crossover, limits spread, and exposes lot size, stop loss, and take profit as inputs.

  2. 02

    Review the complete .mq4 artifact

    Inspect the event handlers, indicator calls, order selection, price normalization, and error paths. Ask the agent to explain or change a specific block without starting over.

    Explain the one-order-at-a-time guard, then add a magic-number filter without changing the crossover rule.

  3. 03

    Check syntax, then test in MT4

    Use the static syntax checker for compiler diagnostics. After the source is clean, compile it in the target MetaEditor and test behavior in MT4 Strategy Tester or a demo account.

    Fix each compiler diagnostic, then list the broker, data, spread, and execution assumptions that still require platform testing.

One complete MQL4 artifact, with clear validation limits

The source stays readable. Static diagnostics catch compiler issues; MT4 remains the authority for execution and tests.

SimpleMovingAverage.mq4

Complete custom indicator
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrDodgerBlue

input int InpPeriod = 14;
double OutputBuffer[];

int OnInit()
{
   if(InpPeriod < 2)
      return(INIT_PARAMETERS_INCORRECT);

   if(!SetIndexBuffer(0, OutputBuffer, INDICATOR_DATA))
      return(INIT_FAILED);

   ArraySetAsSeries(OutputBuffer, true);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrDodgerBlue);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexLabel(0, "Simple MA");
   IndicatorShortName("Simple MQL4 MA");
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   if(rates_total < InpPeriod)
      return(0);

   int limit = prev_calculated == 0
      ? rates_total - InpPeriod
      : rates_total - prev_calculated + 1;

   if(limit > rates_total - InpPeriod)
      limit = rates_total - InpPeriod;

   for(int index = limit; index >= 0; --index)
      OutputBuffer[index] = iMA(NULL, 0, InpPeriod, 0,
                                MODE_SMA, PRICE_CLOSE, index);

   return(rates_total);
}

What the checker returns

Compiler diagnostics for the submitted source, including line and column locations when MetaEditor provides them.

What still belongs in MT4

Terminal compilation, chart behavior, Strategy Tester results, broker permissions, fills, and demo or live execution.

The current file boundary

One self-contained .mq4 file. Multi-file projects, DLLs, private libraries, compiled EX4 output, and resources are outside this workflow.

A language-specific workflow, not just another prompt

The difference is the connected artifact, MQL4 context, diagnostics, and memory. Platform testing remains required.

Workflow areaPineify MQL4 AgentGeneral AI chat
MQL4 language contextVersioned reference derived from official MQL4 documentationDepends on the model, prompt, and current context
Code outputEditable, single-file .mq4 artifactUsually an isolated chat response
Syntax feedbackSource-located MetaEditor diagnostics in the workflowUsually requires manual copy and paste
Language preferencesDedicated MQL4 memoryVaries by product and session
Runtime and trading validationStill requires MT4 compilation, testing, and reviewStill requires MT4 compilation, testing, and review

MQL4 tasks that fit the current single-file scope

Build an Expert Advisor

Turn explicit entry, exit, order ownership, spread, lot-size, stop-loss, and take-profit rules into inspectable MQL4 source.

Create a Custom Indicator

Generate a single-file indicator with inputs, buffers, plots, closed-bar calculations, chart objects, or alerts.

Repair Existing MQL4

Continue from an existing .mq4 artifact, inspect compiler diagnostics, and apply a focused fix while preserving intended behavior.

Rebuild Logic for MT4

Translate the intended behavior of Pine Script or MQL5 into MQL4 APIs, then review platform differences instead of relying on a literal syntax swap.

Buy Once. All Tools. Forever.100,000+ Traders Already Upgraded

One-time payment · No subscriptions · Lifetime access

⏰ Lifetime pricing is going away

We're moving to annual subscriptions soon. This is your last chance to lock in a one-time payment for lifetime access.

💡 Once we switch, lifetime access will no longer be available

Plus

$129$99One-time payment
Advanced Model + 500 AI credits/month — pay once, use forever!
Save 20%
Get Lifetime Access

AI usage included

AI credits
500/ month
Advanced Model
100msgs / 5h
AI Chart Analysis
2/ day

Advanced Model messages use no AI credits.

Core tools

  • Coding AI Agent

    Multiple platforms · Knowledge Base, Auto Fix Error & Memory

  • Visual Pine Script Editor
  • Exclusive PineifyGPT access
  • 18 premium scripts

Also included

Best Value Plan
2xUsage

Advanced

$219$149One-time payment
2x AI power — 1000 credits/month + premium trading tools
🔥 Save 30%
Get Lifetime Access

AI usage included

AI credits
1,000/ month
Advanced Model
200msgs / 5h
AI Chart Analysis
5/ day

Advanced Model messages use no AI credits.

Everything in Plus, plus:

Added in Advanced

  • AI Finance Agent
  • AI Stocks & Options PickerNew
  • Strategy Optimizer Extension
  • Backtest Report Deep Report
  • Trading Journal
Maximum AI Power
5xUsage

Expert

$369$259One-time payment
Full access to every tool + 5x AI power — 2500 credits/month
🔥 Save 30%
Get Lifetime Access

AI usage included

AI credits
2,500/ month
Advanced Model
500msgs / 5h
AI Chart Analysis
20/ day

Advanced Model messages use no AI credits.

Everything in Advanced, plus:

Added in Expert

  • Market InsightsHot

    Options Flow, Opportunities, Dark Pool, Market Tide & more

  • Market ScreenerNew
  • Analyst RatingsNew
  • MCP Access for AI Agents
  • AI Trading Agent
  • AI Daily Portfolio Report
  • Access Mobile App

Also included

  • Request custom indicators
  • Priority access to new features
  • Lifetime feature updates
See what's included in each plan
Payment Security

Frequently asked questions

MQL4 generation and syntax checking are development aids. MT4 compilation and testing remain part of your release process.

What is an MQL4 AI Coding Agent?
An MQL4 AI Coding Agent turns plain-language requirements into editable MQL4 source for MetaTrader 4. Pineify keeps the result in a code artifact so you can inspect the complete .mq4 file and request focused changes.
What types of MQL4 programs can Pineify generate?
The current workflow generates one complete, self-contained .mq4 source file for a MetaTrader 4 Expert Advisor, custom indicator, or script. It can include helper functions, inputs, event handlers, trading rules, indicator buffers, alerts, and risk controls that fit that single-file contract.
How does MQL4 syntax checking work?
Pineify sends the current .mq4 source to an independent MetaEditor service for a single-file static syntax check. Compiler diagnostics return with source locations that the agent can use for a focused revision. A clean check does not prove runtime behavior, backtest results, broker compatibility, or live-trading safety.
Does the agent use official MQL4 documentation?
Yes. The MQL4 coding context includes a versioned static reference derived from the official MQL4 documentation. It focuses on common language rules, program lifecycles, timeseries, indicators, chart objects, files, errors, and classic order APIs used in single-file MT4 programs.
Can Pineify edit existing MQL4 code?
Yes. Start with an existing MQL4 source file or continue from a generated code artifact, then ask for a targeted repair or behavior change. MQL4 also has dedicated language memory for conventions you want to reuse across chats.
Does it support multi-file MT4 projects, DLLs, or custom libraries?
No. The current generation and syntax-check workflow targets one self-contained .mq4 source file. It does not claim to package multi-file projects, external DLL integrations, private library dependencies, compiled EX4 files, or terminal resources.
How does MQL4 support differ from MQL5 support?
MQL4 and MQL5 are separate targets in Pineify. When MQL4 is selected, the agent uses MQL4 prompts, reference context, memory, .mq4 downloads, and the MT4 syntax-check service instead of silently substituting MQL5 trading classes or position APIs.
Can an AI-generated Expert Advisor guarantee profits?
No. Syntax checking only evaluates source diagnostics. Trading rules can still be flawed, overfit, or unsuitable for a broker or market. Review the code, compile it in your target MT4 installation, backtest it with explicit assumptions, and use a demo account before considering live trading. Pineify is not investment advice.

Start with one reviewable MQL4 file

Define the MT4 behavior, inspect the generated .mq4 source, use diagnostics to repair it, and validate the result in your own MetaTrader 4 environment.

Select MQL4 in the language menu after the Coding Agent opens.