文章 "在MQL5中构建自适应的自动化交易系统(EA)" - 页 2

 

感谢您的宝贵承诺,尤其是为我们提供了开阔视野的机会--我认为这才是最重要的。

我有一些实际的、也许是幼稚的问题

  • 如何使用 "神奇数字 "和 "评论 "来跟踪 EA?
  • 如何修改 LotSize(甚至更好,如何实施资金管理)?

谢谢

祝您愉快

 
Gamuchirai Zororo Ndawana #:
我喜欢你的主动方法。你说得对,在尝试获取历史数据时,可能会出现一些异常情况。例如,如果您试图在交易时段中间更改时间框架,可能会再次出现"-nan "问题。


在保持信息简明易懂和修复我观察到的所有错误之间存在着固有的权衡。如果我选择后者,代码可能会变得更加复杂,也不容易理解。因此,我决定让它简单易懂,并希望你能快速扩展它。

你的解决方案听起来很有前途,结果如何?

您好,我必须重新创建账户才能登录。总之,
,我试着运行了线性回归(LinearRegressionEA),发现这是一个令人兴奋的概念。我主要交易黄金差价合约(GOLD CFDs),并喜欢上了这个示例中的 WPR 指标。
,有时我得到的预测价格不正确,超出了 100 倍的范围,但有时是正确的!
,如果有人能解决这个问题,我会非常感激。调试线性回归代码不是我的专长。

我没有看到您是否写过关于首选交易时间段的内容,我将其设置为 30 分钟。

在这种情况下,
,如果还没有交易,
,EA 运行"analyse_indicators()"函数,
,每个条形图执行一次,所以在我的情况下,每 30 分钟执行一次。
因此,这意味着如果指标不符合交易决策,直到下一个条形图(在我的情况下是 30 分钟后)才会再次尝试。

因此,我添加了一个定时器任务,每 10 秒运行一次分析步骤,直到指标有利于交易;
,我建立买入或卖出订单,然后返回到manage_position() 函数的常规每条处理。
 
Giulio Braga 资金管理)?

谢谢

祝您玩得愉快

嘿,Giulio。

要设置神奇数字和自定义注释,您只需调用相应的函数来扩展代码即可。

我认为 PositionOpen 可能就是你要找的函数,你可以通过这个链接 查看文档。

如果这还不能满足你的需求,可以通过这个链接 试试 YouTube 上的教程。

如果这些资源都无法帮助你,那么我有一个频道,在那里我发布了更多类似的有用文章。您可以使用此链接 找到它。

Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionOpen
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionOpen
  • www.mql5.com
Opens a position with the specified parameters. Parameters symbol [in]  Name of trade instrument, by which it is intended to open position...
 
Gunnar Forsgren #:
您好,我不得不再次创建账户才能登录。总之, ,我试着运行了线性回归(LinearRegressionEA),发现这是一个令人兴奋的概念。我主要交易黄金差价合约(GOLD CFDs),并喜欢这个示例中的 WPR 指标。 ,有时我得到的预测价格不正确,超出了 100 倍的范围,但有时是正确的! ,如果有人能解决这个问题,我将非常感激。调试线性回归代码不是我的专长。 我没有看到您是否写过关于首选交易时间段的内容,我将其设置为 30 分钟。 在这种情况下, ,如果还没有交易, ,EA 运行








"analyse_indicators()"函数, ,每个条形图执行一次,所以在我的情况下,每 30 分钟执行一次。因此,这意味着如果指标不符合交易决策,直到下一个条形图(在我的情况下是 30 分钟后)才会再次尝试。 因此,我添加了一个定时器任务,每 10 秒钟运行一次分析步骤,直到指标有利于交易; ,我建立买入或卖出订单,然后返回到




管理头寸() 函数的常规每条处理。
很高兴收到您的回信,Gunnar。

很抱歉听到您遇到登录困难,我相信您现在已经解决了这个问题。

您说得没错,我们当前模型给出的预测有时可能会超出可接受的范围很多,但代码中并不存在错误。

让我解释一下为什么我们可以预期会发生这种情况。

我们正在使用梯度下降算法的简单实现来优化我们的模型系数。不幸的是,梯度下降算法对系数的起始位置很敏感。为了解决这个问题,我们开发了随机梯度下降算法(SGD)。随机梯度下降算法通过每次改变起始系数来进行优化,从而最大限度地提高找到最优系数的概率。为简单起见,我们保持系数固定不变,这可能会导致模型陷入低迷状态。

是的,你是对的,我有意要求对每根 蜡烛都进行计算。要关闭此功能,只需删除条件检查 "if(timestamp != current_time) "即可。

此外,我们还可以通过一些方法来构建模型,使其能够根据手头的数据进行定制,您可以使用此链接 查找相关信息。
134 - What are Optimizers in deep learning? (Keras & TensorFlow)
134 - What are Optimizers in deep learning? (Keras & TensorFlow)
  • 2020.06.18
  • www.youtube.com
microscopy, python, image processing
 

嗨,太棒了!谢谢!

我看到了这几行字:

2024.06.08 07:00:42.212 Core 01 2024.05.01 00:00:00   Validation mae: 
2024.06.08 07:00:42.212 Core 01 2024.05.01 00:00:00   [inf,0.006448762386408615,0.006380585312229991,0.006373808727022462,0.006373131478053022,0.006373063757231861,0.006373056987294832,0.006373056310301126,0.006373056241302974,0.00637305623338131,0.00637305623026851,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.006373056230211261,0.0

如何解决这个问题?

有人也遇到过这个问题吗?

 
Javier Santiago Gaston De Iriarte Cabrera #:

嗨,太棒了!谢谢!

我看到了这几行:

如何解决这个问题?

有谁也遇到过这个问题吗?

嘿,哈维尔,你能上传更多终端的输出结果吗?

因为你分享的结果看起来很正常,我也希望有这样的输出结果。

不过,我注意到你的输出结果有一个问题,那就是最后的 "0.0"。误差为 0.0 意味着模型是完美的,这在现实中是不可能的。


 

你好,加姆奇莱、

(我希望这是一种公认的打招呼方式)。

我一直在饶有兴趣地阅读您的文章,因为我非常渴望找到改进我非常幼稚的代码的机会。我刚刚从 MQL4 过渡到 MQL5,没有数学背景。

在回溯测试中运行您下载的代码时,我注意到唯一的交易都是卖出头寸--见附件。

显示预测价格的注释总是显示为 0.0000nnnnnn,这似乎是不正确的。

作为初学者,我无法确定明显的错误出在哪里,因此希望您能给出修正或更正,因为我希望在未来的 EA 中实施回归分析

感谢您的考虑和可爱的言传身教。


亲切的问候,
Bryan

附加的文件:
Regression.JPG  213 kb
 
Giulio Braga # :

Thank you for your valuable commitment, especially for providing us with the opportunity to broaden our horizons - I think this is the most important thing.

I have some practical, if naive, questions.

  • How to use "magic numbers" and "comments" to track EAs?
  • How do I modify the LotSize (or even better, how do I implement money management )?

Thanks

Have a nice day

Man I haven't thought of using the comments to track positions, but it such a simple algorithm that it can't fail, I like it, thank you for that suggestion. Otherwise, magic numbers are well covered in the MQL5 API, just hit F1 on your IDE and then search, or look it up online or in forums, it is well covered.

Money management, has now been covered in our series of articles. I'll find the link for you if you missed it.

 
Javier Santiago Gaston De Iriarte Cabrera # :

Hi, that's great! Thanks!

I saw these lines:

How to solve this problem?

Has anyone encountered this problem as well?

Hello Javier, you know we're on a lifelong learning journey in our community, from what I have learned in the time that has passed since I wrote this article I would say that the implementation is not stable, I'll review this article and update it with more numerically stable solutions. Fortunately for us, there exist compact solutions that could easily solve in one line, what I did in this entire article, if only I knew back then, what I know now.

 
Bryan John Aldridge # :

Hello, Gamchilai,

(I wish this was a recognized way of saying hello).

I have been reading your articles with interest, as I am very eager to find opportunities to improve my very naive code. I have just made the transition from MQL4 to MQL5 and have no mathematical background.

When running the code you downloaded in a backtest, I noticed that the only trades were all sell positions - see attached. The annotation showing the predicted price always shows 0.0000nnnnnn which does not seem to be correct.

As a beginner I can't figure out where the obvious mistake is so I hope you can give me a fix or correction as I hope to implement regression analysis in a future EA .

Thank you for your consideration and lovely words.


Kind regards, Bryan

Hello Bryan, your concerns are material. Rest assured it is not your fault, the algorithm I implemented in this article is a good start, however it is not stable. I will update this article with stable solutions, that are remarkably easier to implement.