[Development Log] Why does the logic completed in Python "degrade" when used in MT4
In the field of logic development, there exists an structural friction that is surprisingly rarely discussed. It is the problem that the development environment and the delivery environment do not match. While outwardly the verification results and asset curves tend to be talked about, in actual development processes, this “environment mismatch” is the part that consumes the most man-hours.
In-lab logic verification and actual operation are basically completed within a Python environment. Considering the flexibility of data processing, the speed of backtesting, and the ease of statistical validation, it is certainly more rational to complete development solely with Python. In fact, the lab itself conducts its own trades by issuing orders directly from Python to the broker using a drive mode.
However, when delivering logic as a product, the story changes. The vast majority of automatic trading users in the market operate EAs in an MT4 or MT5 environment. In other words, in order to deliver the logic as a product, there is an unavoidable prerequisite to port (reinstall) the logic finished in Python to a completely different language/execution environment called MQL4/MQL5.
1. Python environment and MT4 environment have inherently different design philosophies
Development in Python presupposes vector operations using libraries like pandas and numpy, and a framework for statistical backtesting. On the other hand, MT4/MT5 is an event-driven architecture based on per-tick sequential processing, and the fundamental computational model is different.
Because of this difference, even if you port the same logic, there can be subtle misalignments in indicator reproducibility, how floating-point arithmetic is rounded, and the timing of order processing. This is not due to the porting programmer’s lack of skill, but stems from structural differences in the environments themselves, an inevitable friction.
2. The reality of “even fairly accurate porting still having some missing pieces”
The troublesome part is that this porting work can be reproduced to a high degree of accuracy up to a certain level. When comparing backtest results, it often appears that the behavior is almost the same.
However, when you probe into the details, some of the advantages observed on the Python side are not recreated in the MT4 environment in exact detail. This is not a major logic failure, but rather a slight reduction in edge purity. Because it is invisible, there is a risk of productizing it without noticing if you neglect validation.
3. Cases where porting itself fails and the workload explodes
Furthermore, a more troublesome aspect is that, depending on the structure of the logic, porting may fail altogether in some cases. Conditional branches and statistical processing that could be expressed naturally on the Python side may not be reproducible in the same form due to MQL4/MQL5 language specifications and execution model constraints.
In such cases, simple rewrites won’t suffice, and you may need to redesign parts of the logic using a different approach, often greatly exceeding the expected workload. Behind the glamorous成果 labeled in the development record, there is always steady, sometimes fruitless trial and error.
4. Why this工程 cannot be skipped even so
Then one might wonder if this friction can be avoided by finishing everything in Python alone. In fact, the lab’s own operations are viable that way.
However, there are users who trade daily in MT4/MT5 to whom the logic is delivered as a product. Since the goal is to deliver in a form that reaches the target, there is no option to skip this porting process for the lab.
In other words, this porting process is not merely a task but an essential step to make the developed logic usable by others, and the precision here is what determines the product’s value.
The development realities Semura Lab. faces
For us at Semura Lab., logic development in Python is a relatively controllable process. The truly difficult part is the process of translating the results to the different environment of MT4/MT5 without losing advantage. Therefore, even for the ported EA, we believe we cannot skip revalidation under the same conditions as the Python version and identifying the behavior differences between the two.
Behind the flashy phrase “logic development” lie quiet but unavoidable technical hurdles of translation between environments. In this development log, we intend to honestly record these less visible processes as well in the future.