脚本: BuySell + SL + TP - 页 2

 
emmapeel #:

谢谢你的实用工具。只是有一个问题:我无法修改 LOTS(double Lots = 0.01; // Lots (in pips))。

当我开仓时,得到的总是 0.01。我不是程序员。

感谢您的宝贵时间。

"脚本和其他程序一样,可以有输入变量。不过,对于脚本而言,即使脚本定义了输入变量,默认情况下也不会显示参数输入对话框。为确保在运行脚本前打开属性对话框,应使用#property script_show_inputs 指令 。它的优先级高于script_show_confirm,也就是说,对话框的输出会禁用确认请求(因为对话框本身的作用类似)。即使没有输入变量,该指令也会调用对话框。它可用于向用户显示产品描述和版本(它们显示在常用 选项卡 )"。(脚本 - 创建应用程序 - 面向交易者的 MQL5 编程)。

替换:

double Lots = 0.01;

替换为

#property script_show_inputs

input double Lots = 0.20;
这将在将脚本附加到图表时提供一个可调整的设置。
MQL5 Book: Input variables / Programming fundamentals
MQL5 Book: Input variables / Programming fundamentals
  • www.mql5.com
When launched, all programs in MQL5 can inquire parameters from the user. The only exception is libraries that are not executed independently, but...
 
插入代码 时请 使用代码 按钮 (Alt-S)

版主纠正了这次的格式问题。今后请正确使用代码格式,格式不正确的帖子可能会被删除。

感谢您的回复。

我修改了代码:

#property script_show_inputs

input double Lots = 0.20;      // 手数(点数)
double StopLoss = 200;   // 止损(以点为单位)
double TakeProfit = 400; // 止盈(点数)

但是

error: 'Lots' - constant cannot be modified buy+sl+tp --------.mq5 53 4

附加的文件:
 
emmapeel #:

感谢您的答复。

我修改了代码:

但是

error: 'Lots' - constant cannot be modified buy+sl+tp --------.mq5 53 4

操作员的代码中使用了全局变量(GV)。有了显示输入指令,就不需要全局变量了。此外,也没有点数乘数来将点数转换为点数。在本帖所附代码中,我添加了 SL 和 TP 输入,将 SL 和 TP 输入重新注释为点,并删除了 GV。该代码可编译,但未经测试。

附加的文件: