Common Compile Errors
This page covers common MetaEditor compile problems.
Always start by confirming the install path:
MQL5/Include/ModernUI/ModernUI.mqh
Your EA should include:
#include <ModernUI\ModernUI.mqh>
Cannot open include file
Example message
cannot open include file 'ModernUI\ModernUI.mqh'
Most likely cause
ModernUI is not installed where MetaEditor expects it.
Fix
Copy the Include/ModernUI/ folder into:
MQL5/Include/ModernUI/
Then restart MetaEditor.
Also check
- The folder is not nested as
MQL5/Include/ModernUI/Include/ModernUI/. - The folder name is
ModernUI, notModern UI. - The file exists at
MQL5/Include/ModernUI/ModernUI.mqh. - You are editing the correct MT5 terminal data folder.
Undeclared identifier: MuiRoot, Mui::AppWindow, or another ModernUI type
Most likely causes
- Missing include.
- Include path is wrong.
- MetaEditor did not refresh after copying files.
- You copied only some files instead of the full
Include/ModernUItree. - The docs reference a wrapper not present in your installed version.
Fix
Use the umbrella include:
#include <ModernUI\ModernUI.mqh>
Confirm the full Include/ModernUI/ tree is installed.
Restart MetaEditor and compile again.
Wrong parameters count
Most likely causes
- The function signature changed between docs/package versions.
- The arguments are in the wrong order.
- You are mixing raw control factories with labelled wrapper signatures.
- You omitted an array setup before calling a helper that expects
string &items[].
Example
Raw SpinEdit and labelled LabeledSpinEdit are not the same shape.
Mui::SpinEdit(parent,min,max,initial,step,digits,handler,width,height);
Mui::LabeledSpinEdit(parent,label,min,max,step,value,digits,width,height,hint);
Fix
Check the exact page for the helper you are using:
Handler method does not override anything
Most likely cause
The handler method signature is wrong.
For button click handlers, use:
class SaveHandler : public MuiClickHandler
{
public:
virtual void OnChanged(MuiRoot &root,MuiEvent &e)
{
Mui::ToastSuccess(root,"Saved");
}
};
Do not use older or guessed signatures unless the specific control header uses them.
Error caused by using input as a struct field or variable name
Most likely cause
input is reserved in MQL5.
ModernUI labelled wrapper structs use:
control
not:
input
Example:
MuiLabeledSpinEdit risk=Mui::LabeledSpinEdit(section.body,"Risk %",0.1,10.0,0.1,1.0);
if(risk.control!=NULL)
risk.control.Value(2.0);
Array initialisation errors
MQL5 arrays often need explicit sizing.
Instead of relying on shorthand initialisers, use:
string actions[];
ArrayResize(actions,3);
actions[0]="Save";
actions[1]="Reset";
actions[2]="Close";
MuiButtonRow row=Mui::ButtonRow(parent,actions,0.0,0.0,true);
This is the safest style for docs and buyer examples.
Pointer access errors
If a helper returns a pointer, use pointer syntax.
MuiButtonAction *button=Mui::Button(parent,"Save",NULL,160.0,0.0);
if(button!=NULL)
button.Text("Save settings");
If a wrapper returns a struct, access its fields first.
MuiLabeledSpinEdit risk=Mui::LabeledSpinEdit(parent,"Risk %",0.1,10.0,0.1,1.0);
if(risk.control!=NULL)
risk.control.Value(2.0);
Example file cannot find ModernUI
If a supplied example fails to compile with an include error, the include folder is not installed in the terminal data folder used by that MetaEditor instance.
Use MetaTrader:
File → Open Data Folder
Then copy ModernUI to:
MQL5/Include/ModernUI/
Restart MetaEditor after copying.
Still failing?
Create a minimal file using the quick-start skeleton and compile that first.
Then add one control at a time.
If you open a support request, include:
- exact compile error text
- file name
- ModernUI version
- MT5 build number
- whether a supplied example compiles
- the smallest code snippet that reproduces the error
See Reporting a bug.