LTOptions at a 33% discount during the Year End Holidays.
Tell me More

Sunday, August 19, 2012

How to measure a system's edge

Many traders and authors out there constantly say things like "You need a system with positive edge", "You need to trade with odds on your side". But very few people make a more serious effort at going deeper. What does it mean to have a positive edge? and more importantly how do we measure and mathematically demonstrate that a given strategy has a positive edge?

Well, in today's post I want to address this subject by specifically talking about how to measure the edge of a given entry logic. I will use the Forex markets as I find it easy to program routines and test them on the Metatrader 4 platform. A very popular tool that's also freely available to everyone.

But first, let's define a couple of concepts that will be important:

Maximum Favorable Excursion (MFE): This statistic measures the largest temporary profit that a trade had during the whole time it was open. That is, if you entered a trade based on some logic, and you closed the trade x number of bars later, MFE measures the most favorable balance that the trade had during those x bars.

Maximum Adverse Excursion (MAE): MAE measures the largest temporary loss of trade during all the time it was open. That is, if you entered a trade based on some logic, and you closed the trade x number of bars later, MAE measures the most negative balance that the trade showed during all that time it was open.

Let's say for example that you enter a Long (BUY) order on EURUSD at 1.3000.
Your trade goes down to 1.2980, that is 20 pips against you, but then it reverses and goes up to 1.3050.
Now it is 50 pips in your favor. You decide to stay in the position.
A few minutes later EURUSD drops to 1.3040 and you decide to exit for a profit.

As a result, you had a profitable trade that yielded +40 pips, but your Maximum Favorable Excursion (MFE) was 50 pips. That is the most the trade went in your favor while it was open. On the other hand, the trade presented a Maximum Adverse Excursion (MAE) of 20 pips, that is the worst this position was, got to be 20 pips against you.

In order to analyze and quantify the edge of your entry logic, you need to calculate the MFE and MAE for as many past trades as possible. All the entries of course based on the same entry logic you are trying to evaluate.

Finally you calculate the average of all the MFE values and the average of all the MAE values. If the average MFE is greater than the average MAE, then the entry has a positive edge. The greater the MFE in respect with the MAE, the more pronounced and favorable the edge of your entry logic. This is the basis of what is called a Mathematical Expectancy Analysis.

Important: When you do a Mathematical Expectancy analysis of an entry logic, you are not evaluating position sizing, or exit logic or anything. You just determine what would have been the entry point and direction of a trade, and then you calculate the MFE and MAE a number of bars later. If you want your study to be more thorough you calculate the MFE and MAE 10 bars after the entry, 15 bars after the entry, and 20 bars after the entry. Or any number of bars for that matter, and that will show you whether your edge is more significant right after entering the position, or if it is expressed after a while being in the position.

Let's say I have a system with an entry logic that after 10 bars provides an average MFE of 50 pips, and an average MAE of 40 pips. And let's say the study was carried out for a 10 year period during which the entry logic materialized 1000 times. Well, this is a good candidate, and apparently an entry with a positive edge. Judging by the MFE and MAE values alone, you can design a simple exit. If you put your Stop Loss at 45 pips, that is five pips beyond the Maximum Adverse Excursion, and Target Profit also at 45 pips, that is 5 pips below the Maximum Favorable Excursion, then on average this system is bound to reach Target Profit more often that it reaches Stop Loss, and over time it should result in a growing equity curve.

Now, in terms of system design, you should never define a static, hard number of pips as target or stop loss. The reason is that over time, the volatility of a currency pair might and will change. For example, maybe the EURUSD usually moves 120 pips a day today, but in 10 years, days of 200 pips could become the norm. Nobody knows. That's why it is dangerous to set TP and SL with hard numbers of pips assuming the currency will be as volatile in the future as it is right now, or as it has been in the past. You need to determine you targets and profits based on the current volatility, and your Mathematical Expectancy Analysis, should also be done using a measure of volatility rather than hard numbers of pips.

How to include volatility in your Analysis.

One of the most efficient ways to measure the distances is to use a percentage of the Average True Range (ATR) to calculate your MFE and MAE, and likewise, your system would determine Target Points and Stop Loss levels dynamically based on entry price plus/minus an appropriate percentage of the Average True Range that is beneficial according to the Mathematical Expectancy Analysis.

The Average True Range measures the average size of the most recent bars in history. The usual configuration is the last 14 bars.

Now, if a trade moves 50 pips in your favor, when the Average True Range at the time was 80 pips, you wont report a MFE of 50 pips, instead you will report a MFE of 62.5% of the ATR.

Now, you run your analysis for 10 years again and you obtain that your entry logic has an average MEF of 60% of the ATR, and an average MAE of 40% of the ATR for all the entries after 15 bars.

Well, at this point you can determine that if you put your Targets not 60% but a little below, say 55% of the ATR away from the entry price, and Stop Losses 45% of the ATR away from the entry, your system is bound to hit TP more often than SL and also your winners will be bigger in this case, as the TPs are larger than the SLs. When the entry logic presents itself your system verifies the value of the current ATR and calculates the number of pips necessary for TP and SL. In this case let's suppose we have a signal to go long, and current ATR is 100 pips. Well the Target Point will be 55 pips above the current entry price (55% of ATR) and the Stop Loss should be set 45 pips below entry price (45% of ATR). Obviously, for other trades, the number of pips for TP and SL will be different because the numbers will always be calculated based on the volatility at the moment, reflected by the current ATR.

Well, I hope this explains part of the mystery of the phrase: "you need a system with a positive edge". It took me a while to find information about it and a lot of reading to grasp the concepts and put the different pieces together.

In future articles I will evaluate and discuss whether an entry based on some indicator's behavior has a positive edge or not. I will begin by analyzing the MACD Divergence Indicator built by me a few months ago. I will demonstrate whether it is possible to create a system with a positive edge, based only on MACD Divergences, and I will also evaluate which MACD Divergences are better to trade, Hidden or Classical Divergences, or whether they are useless and do not offer a positive edge over a significant number of trades.

Stay tuned!!

Related Articles:
Risk/Reward, Profit Factor and Profitability of trading strategies
An analysis of Classical Divergences for the EURUSD
Design of a EURUSD Donchian breakout strategy 
Useful resources for learning about mechanical trading systems

Go to the bottom of this page in order to see the Legal Stuff

1 comment:

  1. Wow, that was some great information and research. I think that you may be on to a great discovery with this insightful analysis!