Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
文章《在 MQL5 中创建用于交易的活动控制面板》中使用了OnChartEvent 。
我的意思是 :OnTrade( )
应为OnTrade( id, para1,para2.....)
是否有人可以改进文章中给出的代码,以处理 通过止损或止盈平仓的事件?
自该文章发表以来的两年半时间里,是否已经证明没有必要使用该代码了?
建议先翻译,https://www.mql5.com/en/articles/211 Orders, Positions and Deals in MetaTrader 5
先弄清上面的6+2里面对应Orders, Positions and Deals 的那一个!
对于 MQL4,您能想到与 OnTrade 类似的方法吗?
检查每个跳动点的 OrdersTotal() 和 OrdersHistoryTotal() - 如果数字发生变化 - 调用 OnTrade()。
嗨 、
感谢您写这篇文章...我对您的代码进行了一些尝试。但一开始我遇到了一个基本问题,那就是我正在处理位置问题。也就是说:
我的 EA 在回溯测试 中设置了一个买单,并且 Ontrade 函数被多次调用。但您的代码只检查 OrdersTotal。奇怪的是:这个函数的结果总是 0。下单后,我只有一个买入头寸,而您的代码没有处理这个头寸,不是吗?
这里出了什么问题?
对于 MQL4,您能想到与 OnTrade 类似的方法吗?
在进行交易操作前 生成 OnChartEvent(),并在其中尝试获取交易操作的结果....。您还可以想出一种类型,根据这种类型,OnChartEvent() 应该调用必要的次数...
如果没有图形元素,我们为什么需要这种变量?在我看来,这是不必要的...