Purely Statistical EA

[B]Before we get started…[/B]
Hey everyone, it’s been a very long time since I have been plugged into these forums. I have let my “Price Action That Matters” thread retire because I found myself spending more time in these forums than I was focusing on trading/investing. For those who were around back in the day and were wondering what I have been up to, here is a quick update. As most know I created a system that monitors gas/liquid pipelines, and have been spending a significant amount of time getting the company started and going. The company has really exploded and we are now installed on over 100 pipelines and the company continues to grow exponentially. The little bit I have left I spend trading/investing/researching market theory/studying towards various certifications. That means I still don’t have much time but I wanted to come back and use these forums to post and discuss trade theory/trading systems/etc.

I will lay out my “lines in the sand” for my threads. Everyone is welcome here from the beginner to the most learned, and I believe all will benefit. I will [B]not[/B] be answering basic questions about trading, or any other really basic level questions. There is plenty of google material to learn all of that on your own time. If you do ask basic questions, expect to be ignored. I will of course be open to discussing idea’s in these threads, but will for the most part just be posting results, findings, etc. Finally, don’t ask for my code/EAs/one-on-one training sessions, because it just ain’t going to happen. Hopefully you will get enough nuggets of wisdom from this thread to better your own methodologies.

[B]Now let’s get started…[/B]
In my years of studying market theory, technicals, trade management, etc; the key to a successful EA is a lot more related to using statistical analysis to properly handle trades than it is about finding the right combination of indicators and indicator settings. In the spirit of that theory, in this thread I am going to be presenting results from tests that I am doing on using price movement statistics to gain a statistical edge over entering and exiting trades. You could call it a trade management only method, or trade management on steroids. That means there are no technical indicators involved, no special time frames; just trade logic using price and time statistics. Not that indicators won’t eventually be added but we need to put things in proper order to end up with positive results.

To me a successful method would be one that has little draw down, short duration of draw down, doesn’t rely purely on indicators, works across a broad range of conditions and pairs, takes a statistically significant amount of trades over a statistically significant amount of time, and the forward testing performance closely tracks backtesting performance(no curve-fitting). This is not to say that it doesn’t perform better during certain market conditions, but the goal is for it to have the broadness and flexibility to run through every market condition and still have an edge. Why? Because once you have a statistical advantage with trade management, then you have the groundwork laid for an EA that you can add indicators to, that will focus on targeting those conditions it performs more optimally, thus increasing it’s viability and profitability. 99% of EA’s never work out because the focus is on indicators first and trying to isolate a specific market condition, and then building little or no mechanism to get a statistical advantage over entering/exiting trades.

Does this all seem a little too vague and hard to understand? Well it is, which is why successful EAs are a rare breed. Here’s a summary, a “statistical first/technical last” approach is what we are going for here. If the EA uses something other than price/time/trade management, then it’s outside of the scope of what we are looking for here. Once an advantage can be achieved in this way, then indicator(s) can be added on top to find the market conditions that give you an even better statistical edge by isolating a certain market condition that your trade management logic performs better in. If this still doesn’t make sense, just hang around and you may walk away with something of value.

I don’t want to give away to many nuggets of knowledge right now or I won’t have much left to post. More to come!

Feel free to post your own ideas/theories/tests!

Does that mean you’re going to use a random generator for whether you make a buy/sell trade? I’ve been doing some tests myself trying to push the limits of a Random Martingale EA for fun.

EDIT: Well, not for fun - rather to understand most of the EA’s out there that posts 90%+ win rate, only to fail with a death sequence. Without knowing the direction in advance (in backtesting), I was able to push some random martingale to some impressive figures. Not trading them of course - but it helped me build a set of stats that help me identify Martingale behaviour in other people’s EA.

Thanks for throwing your hat in the ring. I use unrealized pnl for my drawdown, rather than realized. That keeps things realistic and keeps me from writing systems that would suddenly blow up my account by accruing huge losses that I may not see. I do think there is value in writing/testing martingale systems, if not just for the purpose of furthering your knowledge of statistical analytics which will ultimately help you better write successful trading systems.

I have come to some significant conclusions for trading in general based on several weeks of intensive tests with random martingale EA’s that I’ve built. It would be rude to steal the limelight from you, so I’ll leave my thoughts until you make mention of it. Besides, I like independent studies to contrast my thoughts on :slight_smile:

So you’ll be monitoring equity rather than balance - good choice. I’m excited about your thread here. Looking forward to your next posts.

I decided to start with a basic grid system. I had a couple theories about how to improve the edge on a grid system, so I added in the logic to test those out. Those were a dynamic growth option, restore on reversal option, and a reversal weighting factor option. It took me a while to work out all of the kinks in the code but I think they are all worked out now so I ran some testing. At this stage of EA development the system is ‘always trading’ and is not looking for any specific market conditions. The goal at this point is to know I have a trading edge with the entry/exit logic regardless of market condition. With an EA always trading, positive results that fit our criteria(read first post to find out what that criteria is) for a good backtest are going to be a lot harder to come by. But when it does happen you have a lot more confidence in your results being genuine, and a lot of room to mature the EA by being able to isolate those market conditions it performs most optimally in.

I attached some screenshots of 1 such test that seems to fit all of the criteria I was looking for. Unfortunately there isn’t as much historical data in the Forex world as there are with equity markets which makes testing systems a lot harder. For my testing I like to backtest between 2002 and 2010, and forward test between 2010 to today. My backtest made over 500 trades and my forward test around 400, which to me is about what I am looking for when trying to find that statistically significant number of trades. I would also be looking for my forward test period to do as good or better than my backtest period which in this case it did. If forward testing does significantly worse, I throw out the test and move on.

Backtest



Backtest/Forward Test



I’m glad to see someone who has already been down this path a ways and can contribute to the discussion! You can go ahead and post your thoughts about the testing you have been doing, or wait for me to post some of my testing results first. It’s up to you.

Thanks, I’ll keep this in mind.

Good results, especially considering that the tests cover over 14 years. Most EA’s don’t last that long.

The first thing that sticks out to me at the moment is that the returns are lower than profits from interest rates (1.05)^14.

Keep it up though, you’ve got room to move with the low equity drawdown.

I did some more testing today with good results. I will post some of that when I have time to dig through it.

At this phase I am not looking at net profitability, just the metrics of volatility, profit factor and other absolute values. For example I could increase the size of lots of this backtest by x10, and I would have a net profit of $390,000 rather than $39,000, and a drawdown of 40% instead of 4%. I don’t focus much on metrics that are a function of a number I can play with such as lots risked, which is why I focus mainly on the absolute performance metrics.

But so far things are looking good!

Ah okay, so as long as your risk grows linear rather than exponential to lot size it’ll be fine. I know some EA’S out there that don’t do too well with increasing lot size.

Another ratio you might be interested in is profit /equity drawdown. Note that I use equity, not balance. I use this figure as a risk/reward ratio - it measures how much we would tolerate as a drawdown relative to when one would take profit.

On random martingales, this figure tends to be quite low due to exponential losses made as the shares goes deeper in the rabbit hole.

In theory, what would make more sense from a trading perspective is to have a high profit/equity drawdown. This enforces good behaviour of selling losses quickly and riding profits above and beyond the drawdown %. Hard to achieve in practice, but good practice anyways.

I’ll see if I can dig out an EA that illustrates this later.

I wanted to drop a line about where I am at right now. Over the past week a did a number of things to really clean up the testing and am getting better, more consistent results. The first thing I did was clean up the code. There is too much to get into here, but overall I cleaned up the logic, was able to find a few small bugs, and reworked some of the logic and which ended up producing better results.

I also dug through the historical data on MT5 and found the data was increasingly poor quality pre 2006. So I changed my backtest from 2006-2011 and my forward test from 2011-2016, which gives me a good 50/50 testing period. I also noticed that from 2006-2010 the spread for the EURUSD is fixed at 2 pips, and starting 2010, it becomes dynamic. Most likely they didn’t have full bid/ask history which is why the fixed 2 pips. That is fine though for 2 reasons, first is that my EA isn’t a scalper, so very small 1-2 pip differences shouldn’t make much of a change to the EA results. Second reason is that many brokers you can now get between 0.1-1 pip spread, so if my EA performs well with a fixed 2 pip spread, running with a smaller live spread should be to its benefit.

The last thing I did was change it’s entry window to the Europe/US session which helped it get in the market at much better times.

I still haven’t added any indicators to the logic so I am excited about the great performance it is currently having without any and how much more potential it will have once I start tailoring it to specific market conditions using some indicators. I have yet to do a full optimization to see how the various features I have added fair, but I ran a quick optimization with just a few features turned on to see what it would spit out. There were quite a few very promising results. I have yet to run forward testing on this.