Self-Learning Forex Expert Advisor

After a little e-mail conversation with one of my site’s visitors about the statistical expert advisor, example of which I shared publicly in August 2008, I’ve remembered about a more advanced version, which, while still isn’t profitable, can be a much better example and foundation for the future self-learning statistical EAs in Forex. The expert advisor that I’ll share in this post is a corrected and then slightly modified version of the EA that was used by me in MetaQuotes‘ Automated Trading Championship 2008. Although I’ve started very well in that competition I finished with a very bad result. There were several problems in the version used in the championship that were fixed in the current version of the EA. But it’s still not profitable and shouldn’t be used for live trading without a thorough modification and testing.
If you aren’t acquainted with concept of the self-learning EAs or statistical trading systems, please read the following posts:

  • Statistical Forex Systems
  • shared publicly
  • In short, the self-learning EA “learns” from the market and places the positions according to his previous “knowledge” about the market. The presented EA — RowLearnerCorrectedFinal, uses OHLC (Open, High, Low, Close) data of the 6 previous bars and the resulting outcome of the latest bar (drop, rise, or flat) as the primary knowledge about market. The OHLC data is also normalized by subtracting the current Open level to make the “knowledge” more independent from the actual market levels. To decide the direction of the positions, the EA finds the lowest average Euclidean distance between the current market state and all the remembered states. It also has a money management system implemented (quite aggressive, left from the championship). You can download RowLearnerCorrectedFinal (or zipped) for free.
    The expert advisor is available only for MetaTrader 4, because I still have a lot of issues with the MetaTrader 5 order handling. Because it’s not profitable, I didn’t add it to the list of MT4 EAs on my site.
    How to use it:

  • RowLearnerCorrectedFinal and copy to your MetaTrader’s /experts/ folder.
  • You’ll need to create a map-file with the market “knowledge” for EA.
  • Open the EA in MQL Editor and comment out lines 59 and 87–106.
  • Compile it.
  • Run it in a strategy tester on EUR/USD, H1, Open prices only, any period (the longer is the better).
  • “rl.txt” file will be created inside /tester/files/ folder of your MetaTrader.
  • Copy it to /experts/files/ folder.
  • Open the EA in MQL Editor and uncomment lines 59 and 87–106.
  • Compile it.
  • You can now attach it to EUR/USD H1 chart. It will trade and continue learning. On deinitialization it will save its data to “rl.txt” located in your /experts/files/ folder.
  • There are three known problems with this Forex expert advisor that make its use unprofitable:

  • Basing the market knowledge on the OHLC patterns of the previous bars proved to be ineffective.
  • If the market significantly changes its behavior compared to the period of learning, the EA fails to trade profitably.
  • If the range of prices changes significantly, the previous data proves to be pretty useless.
  • Possible ways to improve this self-learning MT4 EA:

  • Find better market parameters to store as the EA’s knowledge (Heiken-Ashi, various pivots, indicator values, etc.)
  • Provide better learning pattern — not just buy, sell or hold if the Close-Open difference of the next candle after the pattern was inside/outside a certain range of pips.
  • Find better coefficient system to weight the older data compared to the newer.
  • Add more maps with different data that can’t be compared with the data stored in the primary map (for example, a separate map for Volume data).
  • Use other distance measuring method instead of Euclidean (Mahalanobis, Manhattan, Chebyshev, Minkowski, etc.)
  • Find a different way of applying the distance — using the average distance, using the shortest distance, using the median distance, etc.
  • You can freely modify, upgrade and use the pieces of code from this EA as long as you leave the credit to the original author (me) inside the MQL file. If you manage to get something worthy out of it, please let me know.

    If you have any questions or comments regarding this self-learning expert advisor, please, feel free to reply via the form below.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    + 14 = twenty four