Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

SelfLearningExperts - MetaTrader 5 Experts - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

SelfLearningExperts - expert for MetaTrader 5

The author rewrote Expert Advisor LSV from MQL4, link to source - https://www.mql5.com/ru/code/9431 .

The Expert Advisor works on price movements, regardless of the time frame on which it works. Price patterns are forming by averaging current market prices. Multiple patterns are formed with different parameters. The number of patterns set in the Nidelt variable. For the first mode, use the dstop parameter, for the second mode, dstop*2, and so on up to dstop*N, where N - is the number of modes. If the price changes to the dstop*N value, a new point of the pattern is captured. The newest points are removed so the pattern has a fixed length of Nidelt points. The more settings a pattern has, the deeper the history it captures. Therefore, the market is tracked to different historical depths simultaneously.

Virtual positions are opened when certain patterns change (market conditions change). The task here is to relate the position to a clear market situation. It is generated as follows: the form represented by the price value sequence code is converted into a binary sequence. If the value of a certain point is higher than the previous value, it is 1, otherwise it is 0. Compute unique morphological numbers in this sequence (i.e. binary numbers converted to decimal numbers).

It can open one to three virtual positions with separate stop loss/take profit, and the stop loss and take profit values ​​of each position are the same. Stop loss/take profit values ​​are defined by the dstop parameter, using dstop*1 for one position, dstop*2 for another position, etc. If the price rises above the Stop Loss / Take Profit probability value, it will add value to the possible rise of the pattern, if it falls - it will increase the probability value of the fall. Its virtual position is opened for each of the three modes: the mode parameters, the mode number (its form) and each value of Stop Loss/Take Profit. Calculations are also performed for each of these combinations on the probability of an upside or downside based on the virtual trade.

If no less than 10 virtual trades are created based on any combination of three parameters (parameters, quantities, Stop Loss/Take Profit), and if the same situation occurs on the market (automatic detection of determined parameter and quantity patterns), in this case it may be considered to open a position in a direction determined by probability based on statistics of Stop Loss/Take Profit values.

Collecting statistics will take a lot of time. As the author of Expert Advisor writes: "This may take weeks". The following methods can be used to speed up the process of collecting statistical data for a tester. However, price changes in testers and the real market can differ significantly. The author recommends this: teach the Expert Advisor in the tester and then run it on a demo account for almost a week. If the Expert Advisor shows positive results (so it will undergo some research), then it can be used on a real account.

The first stage of preparation for the Expert Advisor is to optimize its parameters: Nidel, Nstop, dstop, forg, Probab, NN, delta. At this stage, optimization is performed by turning off the ReadHistory and SaveHistory parameters. After you find an acceptable combination of parameters, you need to perform a test with SaveHistory=true. Then run the Expert Advisor on the account from ReadHistory=true - the Expert Advisor starts working as soon as sufficient statistics are collected in the tester. It is recommended to open SaveHistory when working in the account, so that data can be automatically saved when the Expert Advisor overlearns and is ready to start working when the Expert Advisor is restarted.

When using SaveHistory in the tester, the test learning data is saved in a file after running, and its name is FD_[Symbol]. If the Expert Advisor is tested against the EURUSD file, the name will be "FD_EURUSD", if against GBPUSD, it will be "FD_GBPUSD", etc. The files are saved in the Files folder, which is a common data folder for all terminals. You can find the Universal Data Folder through MetaEditor's main menu - Open the Universal Data Folder. ReadHistory reads data through this folder.

In addition to saving the teaching results, the Expert Advisor also saves two files necessary for the trading process. The names of the files are: FDlast_buy[Symbol][TimeFrame] and FDlast_sell[Symbol][TimeFrame]. Don't pay attention to these files.

The Expert Advisor relies only on the time frame of the period in which the learning data is saved and the shortest time between virtual trades. It is equal to the density of two bars, so there are some differences in the results of the work of the Expert Advisor on different time frames.

The graph shows the learning results of the Expert Advisor on EURUSD M15 under default settings.

SelfLearningExperts - expert for MetaTrader 5


Attachment download

📎selflearningexperts.mq5 (26.97 KB)

Source: MQL5 #1108

Verification code Refresh