---
title: "与其它集成开发环境整合 - 欢迎来到算法交易 - MetaEditor 帮助"
description: "MetaEditor 不仅能令您以 MQL4 和 MQL5 编写代码。 您还可以编辑和编译C++和Python源代码。 此外，您还可以将 MetaEditor 作为 其它开发环境的外部编译器 。 当以 MQL4/MQL5... - 与其它集成开发环境整合 - MetaEditor 帮助"
image: "https://www.metatrader5.com/i/logo_metatrader5.png"
---

[MetaEditor 帮助](https://www.metatrader5.com/zh/metaeditor/help) → 与其它集成开发环境整合

# 与其它集成开发环境整合

MetaEditor 不仅能令您以 MQL4 和 MQL5 编写代码。 您还可以编辑和编译C++和Python源代码。 此外，您还可以将 MetaEditor 作为 [其它开发环境的外部编译器](https://www.metatrader5.com/zh/metaeditor/help/beginning/integration_ide#compiler)。

## 编辑 С++ 代码并编译 DLL

当以 MQL4/MQL5 开发交易程序时，您可以轻松地使用第三方 C++ DLL。 您可以编辑 С++ 源代码文件 (CPP 和 H) ，如同 MQ4, MQ5 和 MQH 一样。 DLL 中的这些文件也可以直接从编辑器编译。 安装在用户 PC 上的 Microsoft Visual Studio 可用于此目的。 若要进行编译，请打开 C++ 文件并按 F7 (编译命令)。

![操控 C++ 的 DLL](https://www.metatrader5.com/i/help/metaeditor/en/compile_dll.png)

| 安装在用户 PC 上的 MS Visual Studio 编译器用于编译 C++ 源代码。 支持 MS Visual Studio 2008 及更高版本 (包括 Express 和 Community 版本)。MS Visual Studio 版本 (32 或 64 位) 应该与 MetaEditor 版本匹配。 |
| --- |

MetaEditor 还提供了将导出的 DLL 函数轻松添加到 MQL4/MQL5 文件的能力。 简单地将一个 DLL 文件从 [导航器](https://www.metatrader5.com/zh/metaeditor/help/workspace/navigator) 窗口里拖拽到打开的 MQ4, MQ5 或 MQH 文件里。

![从 DLL 导入函数](https://www.metatrader5.com/i/help/metaeditor/en/dll_import.png)

## 使用Python脚本

Python语言包含多种机器学习、自动化处理以及数据分析和可视化库。现在，可以通过[Python集成模块](https://www.mql5.com/zh/docs/python_metatrader5)在平台中应用高级语言。

- 可以从交易平台轻松快速地获取交易数据，然后使用Python工具进行分析：可以通过一个命令请求成千上万的交易品种
- 获取账户交易状态和交易历史以计算统计数据
- 按照您自己的算法执行交易操作

Python脚本[直接在平台图表上运行](https://www.metatrader5.com/zh/terminal/help/algotrading/trade_robots_indicators#python)，类似于常规的MQL5程序。

MetaEditor提供用于[Python](https://www.metatrader5.com/zh/metaeditor/help/development/python)开发的特殊集成功能：创建空白脚本的向导、直接从编辑器运行的能力、将消息和错误输出到公共日志的功能等。

![在编辑器中运行脚本](https://www.metatrader5.com/i/help/metaeditor/en/python_compile.png)

## 在其它开发环境中编译 MQL 程序 [#](#compiler)

在使用外部编辑器中的源代码时，MetaEditor 执行文件可以用作编译器。 编译器从命令行启动，指定要编译的文件的路径和名称:

- metaeditor.exe /compile:"<源文件的完整路径>"
- metaeditor64.exe /compile:"<源文件的完整路径>"

| 例如 |
| --- |
| "C:\Program Files\TradingPlatform\metaeditor64.exe" /compile:"C:\Program Files\TradingPlatform\MQL5\Scripts\myscript.mq5" |

### 批量编译目录中的文件

对于批量编译，请将路径设置为文件夹而非文件。 指定文件夹中的所有源代码文件都将被编译。 子文件夹不包括在内。

| 如果源文件已有相应的编译版本，则不会执行重编译。 |
| --- |

以下示例显示 \MQL5\Scripts 文件夹的批量编译

| 例如 |
| --- |
| "C:\Program Files\TradingPlatform\metaeditor64.exe" /compile:"C:\Program Files\TradingPlatform\MQL5\Scripts" |

### 自定义 MQL5/MQL4 头文件文件夹

程序可以使用头文件 (*.mqh) 和资源文件 (*.bmp, *.wav, *.ex4, *.ex5), 它们位于当前平台的工作目录之外 (例如, 同一台电脑上其它副本的 \MQL5 文件夹)。 使用"/include" 关键字指定该文件夹的路径以便进行正确编辑。 在编译过程中，文件将按如下方式搜索:

- 头文件: [指定目录]\include\[path from #include<...>]
- 资源文件: [指定目录]\[path from #resource "..."]

| 例如 |
| --- |
| "C:\Program Files\TradingPlatform\metaeditor64.exe" /compile:"C:\Program Files\TradingPlatform\MQL5\Scripts" /include:"C:\Program Files\TradingPlatform 2\MQL5" |

### 编译日志

指定额外的 /log 关键字以便获取有关编译过程的更多信息。 在这种情况下，在包含源文件的文件夹中创建 <源文件名>.log 编译日志文件。

| 例如 |
| --- |
| "C:\Program Files\TradingPlatform\metaeditor64.exe" /compile:"C:\Program Files\TradingPlatform\MQL5\Scripts\myscript.mq5" /log
日志文件: C:\Program Files\TradingPlatform\MQL5\Script\myscript.log |

### 语法检查

若要不经编译检查程序语法，请使用 /s 和 /log 关键字从命令行启动 MetaEditor (以便检查结果显示在日志文件中)。

| 例如 |
| --- |
| "C:\Program Files\TradingPlatform\metaeditor64.exe" /compile:"C:\Program Files\TradingPlatform\MQL5\Scripts\myscript.mq5" /s /log
带有检查结果的文件: C:\Program Files\TradingPlatform\MQL5\Script\myscript.log |

```json
{"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ {"@type": "ListItem", "position": 1, "item": {"@id": "/zh/metaeditor/help", "name": "MetaEditor 帮助"}}, {"@type": "ListItem", "position": 2, "item": {"@id": "/zh/metaeditor/help/beginning/integration_ide", "name": "与其它集成开发环境整合"}} ]}
{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{ "@type": "Question", "name": "MetaTrader 5: 与其它集成开发环境整合", "acceptedAnswer": { "@type": "Answer", "text": "MetaEditor 不仅能令您以 MQL4 和 MQL5 编写代码。 您还可以编辑和编译C++和Python源代码。 此外，您还可以将 MetaEditor 作为 其它开发环境的外部编译器 。 当以 MQL4/MQL5 开发交易程序时，您可以轻松地使用第三方 C++ DLL。 您可以编辑..." } }] }
```
