Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders


Statistical Forex System — Example MT4 Expert Advisor

August 20, 2008 (Last updated on April 12, 2010) by

After saying so much about the statistical Forex systems, I think it’s time to give an example of one. But first, I have to warn that this exert advisor «as is» wasn’t profitable during tests — it had its losses and gains, but spread losses took over eventually, so I can’t suggest using it on your real money account. This expert advisor is good only as an example of an actual statistical Forex system. It uses Tom DeMark’s pivot points calculated over the last 5 bars, which are then normalized by subtracting the current Open price. I used it on EUR/USD H1 chart, but I believe that it can be used on any other currency pair and timeframe. It consists of two .mq4 files:

The first file is StatGathererExample.mq4 — as it appears from its name, this MetaTrader EA will only gather statistics. Run it via strategy tester on a 1–2 year history period (it doesn’t have to be a good quality history, because it has nothing to do with price ticks, and uses just your OHLC data from bars; just be sure to have enough bars in your chart). This EA gathers statistics over a period of time and stores it to MapPath file («rl.txt» by default) in your /tester/files/ directory. Copy it to /experts/files/ for further use by the actual expert advisor.

And the second file is StatRunnerExample.mq4 — this EA is used for the actual trading and on-the-fly statistics gathering. This EA uses MapPath file («rl.txt» by default) from your /tester/files/ (for strategy tester) or /experts/files/ (for actual use) to get the initial statistics. It also continues to gather its own statistics and appends it to the initial file, saving it after deinitilizing.

You can freely use these examples to construct your own statistical Forex systems. I am also currently developing a statistical expert advisor that would be profitable and I promise to share it after the testing period.

16 Responses to “Statistical Forex System — Example MT4 Expert Advisor”

  1. forexmaster

    Interesting idea. But I don’t want to get into Expert Advisor search mania. I already have a profitable EA and I don’t want to try anything else. Can you comment this product:
    I don’t know why download is not available, but what do you think for statements?


  2. Andrei

    forexmaster, Strategy tester statements are easy to forge. I wouldn’t judge about the PAID EA by those statements.


  3. Louay

    Hello Sir
    I can see you are a professional and respectable man
    I wait your latest StatRunnerExample you promised us to share it please can you hurrying to make it or can you send it by me E-mail

    I wait your response


  4. Andrei

    Louay, You could have already downloaded StatRunnerExample. It’s available through the links in the post.


  5. Bill

    Hi Andrei, I have been looking for a way to back test an EA that trades a group of currency pairs, rather than just one pair (sort of a hedging strategy). Unfortunately, MT4 strategy tester does not support using more than one pair in a test session, for either trading or even data gathering, which would be necessary to logically test the strategy. Your Statistical process, i.e. using multiple testing sessions to gather the data and a run of some kind of trade simulator (whether a MT4 program or an altogether external program to simulate trades and collect profit data), appears to have the potential to help resolve this problem. What are your thoughts on this subject?

    Thanks for you time.



  6. Andrei


    I’d suggest using strategy tester only for gathering the statistics. You can run it several times -for each currency pair you need. Then you’d incorporate all that data and run your multiple currency pair EA on MT4 demo – it allows multiple currency pair trading. Why bother with the back-tester for the statistical strategies anyway?


  7. Tantra


    Thanks for sharing this very interesting work of yours.
    I see that you use Pivot Points and distance to the current bar open as input data.

    I wanted to use Open and Close of the last 5 candles as input data, how can I modify the EA (and the gatherer) to do this?


  8. James

    Hi Andrei

    interesting EA !! , I gathered 3months data and backtesting was impressive. But when I run the statrunnerexample.mq4, on demo account, the result was completely bad and ultimately account blown out. I don’t know the reason why.

    Can you please give some more details for the EA, is it possible to optimize?


    Andrei Reply:

    Backtesting EA on the same data that you’ve used to gather is quite pointless. It’s possible to optimize, but I don’t think that this example EA can be profitable.


  9. James

    Would you share me the details, where the similar EA is available? I completely agree with you point on backtesting. Please share your email id.

    thank you somuch.


    Andrei Reply:

    I wasn’t able to produce a profitable statistical EA yet.


  10. Matt

    Yeah, the hardest part is to create an effective trading idea…


  11. 林焕才



    admin Reply:

    Eh? Could you write it in English, please?



    The EA can be profitable, to solve problems is to make opening and closing spreads are also able to open a single large column, thank you


    admin Reply:

    Don’t quite understand what do you mean? Create an array for storing close-open price gaps?


Leave a Reply

required (will not be published)