Use pseudo intelligent trading program (EA) to improve the efficiency of intelligent trading program optimization (including mql4 code)

   Expert Advisors with multiple indicators take a lot of time to combine parameters for testing. In order to reduce the number of combinations, we can write pseudo-expert advisors (EAs). Pseudo EA is only for special issues of market query, not for trading. We can break down a big problem into smaller ones and solve them individually.

    For example, we can choose the ADX indicator and check whether it can distinguish between a flat market and a trending market. If we can, we may be able to obtain additional information.

     Suppose we have a short-term trading EA, which performs "oscillation trading" (back to the moving average) or "trading with the trend" (trading along the moving average) according to whether the market is sideways. To differentiate, our trading EA should use ADX on a higher timeframe (here 1 hour bars). In addition to ADX, the trading EA may have 5 indicators (for short-term trading management). Each indicator has about 4 setting parameters, and each of them has 2000 different values ​​due to their small step size. This would add up to 2000 5 4 = 40,000. Let's add ADX now. For each parameter combination of ADX, we theoretically have to perform an additional 40,000 calculations.

    However, if we first check the performance of the ADX indicator using a pseudo-EA, we can reduce the number of calculations that need to be performed. We can use a pseudo-EA to generate the output of the ADX indicator and then use these outputs to train a machine learning model. Machine learning models can learn how to distinguish between flat and trending markets without doing a lot of calculations.

    Once we have trained the machine learning model, we can apply it to our trading EA. Machine learning models can help us choose parameters automatically, which will greatly reduce the number of calculations that need to be done.

     This method helps us to optimize expert advisors quickly and efficiently. We can use a pseudo-EA to generate outputs, which are then used to train a machine learning model. Machine learning models can help us choose parameters automatically, which will greatly reduce the number of calculations that need to be done

The fake EA we build does not trade. It only implements three important functions:

  • OnTick(): In this function we check the indicator and judge the market status.
  • OnTester(): In this function we output the final result to our CSV file.
  • calcOptVal(): In this function we calculate the OptVal value, which will be returned by OnTester() to the strategy tester for sorting and genetic algorithms.

The function OnTester() will be called at the end of an optimization pass, returns a special value, and it adds a new line to the CSV file for analysis after the entire optimization has been completed.

Download this article EA otimIndi_Publ.mq4

Pay attention to the two EAs that the author is building:

Easy Deal.ex4https://blog.csdn.net/aa84758481/article/details/128343585

Nerve Knife.ex4https://blog.csdn.net/aa84758481/article/details/126648698

Guess you like

Origin blog.csdn.net/aa84758481/article/details/132035257