MQL5 preprocessor question

Does #property strict Cause an Error in MQL5 Compilation?

Do not assume #property strict caused an MQL5 compilation failure. It is not needed to enable MQL5 type checking, and a minimal script containing it was accepted by the MetaEditor checker used for this review. The official MQL5 property list omits strict, but omission alone does not prove your build rejects it. Follow the exact compiler message and fix unrelated type or API errors separately.

Open the Coding Agent and choose MQL5 from the language menu.

Current MQL5 property pattern.mq5
#property copyright "Your name"
#property link      "https://example.com"
#property version   "1.00"

// MQL5 type checking does not need a strict directive.
int OnInit()
  {
   return INIT_SUCCEEDED;
  }
  • Directive: unnecessary for MQL5 type checks
  • Check: actual message and MetaEditor build
  • Do not infer rejection from documentation omission
  • Then: recompile and fix remaining errors

Check the actual diagnostic

The official table defines code 288 as an unknown property. It does not say that every occurrence of strict produces that error. Check whether the diagnostic actually points to this directive before changing it.

A type mismatch elsewhere in the program has its own cause. Removing a redundant directive does not repair invalid assignments, conversions, calls, or declarations.

Safe migration from older snippets

When adapting an MQL4 example, focus on the APIs and event model. You may omit the redundant strict directive in MQL5, but do not treat its presence as proof of failure or every remaining diagnostic as a migration issue.

  • Confirm the file extension is .mq5 and MetaEditor belongs to MetaTrader 5.
  • Replace MQL4 trade and indicator APIs with their MQL5 contracts.
  • Keep documented #property directives that define version or indicator presentation.
  • Do not mass-delete warnings or casts to make the output quiet.

Verify the result

Compare a minimal source with and without the directive using your installed MetaEditor. Keep the actual diagnostics and repair the first confirmed source error. A successful compile still requires runtime and Strategy Tester checks.

Use a focused diagnostic

The example uses documented MQL5 program properties and omits strict. Indicator files should add their documented window, buffer, and plot properties as needed.

A clean compile or a cleared error code does not prove strategy logic, broker compatibility, backtest quality, or live-trading safety. Reproduce the result in the target MetaTrader 5 terminal and account environment.

Current MQL5 property pattern.mq5
#property copyright "Your name"
#property link      "https://example.com"
#property version   "1.00"

// MQL5 type checking does not need a strict directive.
int OnInit()
  {
   return INIT_SUCCEEDED;
  }
Where Pineify fits

Repair editable MQL5 source with compiler feedback

Pineify can generate or revise MQL5 source and use MQL5 compilation diagnostics during the coding workflow. Keep the exact error, source location, program type, and intended behavior in the request so the change remains reviewable.

Open MQL5 Coding Agent

Pineify does not run your broker terminal, Strategy Tester, market data, or live orders. Validate the final program in your own MetaTrader 5 environment.

Review MQL5 AI Coding Agent capabilities

A practical verification workflow

  1. 1

    Confirm the target language

    Verify the file is .mq5 and is being compiled by MetaEditor 5.

  2. 2

    Isolate the directive if implicated

    If the diagnostic names this directive, compare a minimal example with and without it. Preserve the properties needed by the indicator or EA.

  3. 3

    Compile again

    Press F7 and read the new first diagnostic instead of assuming all errors came from strict.

  4. 4

    Test the migrated program

    Exercise initialization, event handlers, data access, and trade requests in the target MT5 environment.

Frequently asked questions

Does #property strict cause an error in MQL5 compilation?

It is not a reliable diagnosis by itself. The review checker accepted a minimal MQL5 script containing it. The property list omits strict, while code 288 describes unknown properties generally; use the actual message from your build.

Will removing #property strict hide type errors?

No. MQL5 compiler rules still apply. Type mismatch, invalid conversion, and function-contract diagnostics must still be repaired.

Should I remove every #property directive?

No. Keep supported properties such as version and the indicator window, buffer, and plot declarations required by the program.

Check the linked official references for the relevant diagnostic. Compile and test the final source in the MetaTrader 5 build, broker, symbol, and account environment you plan to use.

Continue with reviewable MQL5 source

Provide the exact diagnostic and intended behavior, inspect the generated change, compile it, and verify it in your MT5 test environment.

Open MQL5 Coding Agent