跳至内容

Program Properties (#property)

程序属性 (#property)

每个MQL4程序都可以指定名为#property的额外特定参数,这些参数有助于客户端终端正确服务程序,而无需显式启动它们。这主要涉及指标的外部设置。包含在文件中的属性将被完全忽略。属性必须在主mq4文件中指定。

#property identifier value

编译器将在执行的模块配置中写入声明的数值。

常量类型描述
strict用于严格编译模式的编译器指令(参见更新后的MQL4
iconstring用作EX4程序图标的图像文件路径。路径规范规则与资源相同。该属性必须在主模块中使用MQL4源代码指定。图标文件必须为ICO格式。
linkstring公司网站链接
copyrightstring公司名称
versionstring程序版本,最多31个字符
descriptionstringMQL4程序的简短文本描述。可以存在多个描述,每个描述描述一行文本。所有描述的总长度不得超过511个字符,包括换行符。
stacksizeintMQL4程序大小。执行递归函数调用时,足够大的栈是必要的。
在图表上启动脚本或专家顾问时,至少分配8MB的栈。对于指标,栈大小始终固定为1MB。
当程序在策略测试器中启动时,总是为其分配8MB的栈。
library库;未分配起始函数,具有export修饰符的函数可以在其他MQL4程序中导入
indicator_chart_window在图表窗口中显示指标
indicator_separate_window在独立窗口中显示指标
indicator_heightint指标子窗口的固定高度(属性INDICATOR_HEIGHT
indicator_buffersint指标计算的缓冲区数量
indicator_minimumdouble独立指标窗口的底部缩放限制
indicator_maximumdouble独立指标窗口的顶部缩放限制
indicator_labelNstring为DataWindow中显示的第N个图形序列设置标签
indicator_colorNcolor显示第N条线的颜色,其中N是图形序列的数量;编号从1开始
indicator_widthNint图形序列中的线厚度,其中N是图形序列的数量;编号从1开始
indicator_styleNint图形序列中的线样式,由ENUM_LINE_STYLE的值指定。N是图形序列的数量;编号从1开始
indicator_typeNint指标绘图样式类型。N是图形序列的数量;编号从1开始
indicator_levelNdouble独立指标窗口中第N的水平层级
indicator_levelcolorcolor指标水平层级的颜色
indicator_levelwidthint指标水平层级的厚度
indicator_levelstyleint指标水平层级的样式
script_show_confirm在运行脚本前显示确认窗口
script_show_inputs在运行脚本前显示带有属性的窗口,并禁用此确认窗口
tester_filestring要发送到虚拟服务器的<terminal_data_folder>\MQL4\Files\文件名称
tester_indicatorstring要发送到虚拟服务器的<terminal_data_folder>\MQL4\Indicators\指标文件名称
tester_librarystring要发送到虚拟虚拟服务器上的<terminal_data_folder>\MQL4\Libraries\库文件名称

tester_file、tester_indicator和tester_library属性是描述在虚拟托管中所需文件列表所必需的。

iCustom()函数中调用的指标文件,以及MQL4程序中使用的所有库文件,在迁移过程中会自动复制。

有关程序迁移的更多信息,请参阅文章“如何为迁移到虚拟托管准备交易账户”(https://www.mql5.com/zh-cn/articles/994)。

将文件移动到宿主的示例代码

#property tester_file "trade_patterns.csv"    // file with the data to be read by an Expert Advisor
#property tester_indicator "smoothed_ma.ex4"  // file with a custom indicator specified in iCustom() as a variable

代码中隐式指示指标名称的示例

string indicator_name="smoothed_ma.ex4";
double val=iCustom(NULL,0,indicator_name,13,1,0);

描述和版本号的示例任务

#property version     "3.70"      // Current version of the Expert Advisor
#property description "ZigZag universal with Pesavento Patterns"
#property description "At the moment in the indicator several ZigZags with different algorithms are included"
#property description "It is possible to embed a large number of other indicators showing the highs and"
#property description "lows and automatically build from these highs and lows various graphical tools"

程序启动时显示描述和版本的示例

最后更新于