Many will disagree that entry is an essential part of any trading system. Trend‐followers, usually say that they can spot a trend and jump on board and that its trade management that matters. However, entry determines how soon and how quickly your trade will generate profit or loss. A good entry can use a random exit strategy and still make money, but you cannot exit randomly and make a profit with a random entry.

The entry is your edge, on average it should be significantly better than random entries. It indicates a time and place where there is significant lilelyhood of a positon moving into profit over making a loss.

One of the best methods of scoring how valid our entries are is to calculate the edge ratio or e-ratio for short. *Disclaimer I did not invent the e-ratio.

An explanation of the terms before we get going;

MAE = Maximum Adverse Excursion, the maximum adverse move against our position at each point in time since entry.

MFE = Maximum Favourable Excursion, the maximum favourable move against our position at each point in time since entry.

The diagram below should help clear up the difference between MAE & MFE during a long trade.

To calculate E-Ratio;

- Take all the MAE and MFE values at each period since entry.
- Normalise each value for volatility to make results comparable across different asset classes. We can do this by dividing each value by its ATR.
- Compute the average of all the MAE & MFE values at each bar since entry for the desired time duration.
- Divide the average MFE by average MAE for each period since entry.

We will now be given our e-ratio at each bar since our entry, for example, an e-ratio of 1.13 means that we can typically experience 0.13 units of positive vol at this time since entry.

The code below is a function to provide e-ratio for all bars in a time series. This data can then be subsetted for time and dates of trades. The arguments for this function are;

tw -Trade window to analyse

sd – Direction of trade “B” for buys “S” for sells

dat – Path to ts data

```
eratio <- function(tw = 30, sd = "B", dat = "C:/Users/james/Desktop/Dat/eurusd-1d.txt")
{
require(data.table)
require(lubridate)
require(stringr)
require(TTR)
### Import OHLC data
dt <- fread(dat)
dt$DateTime <- mdy_hms(paste(dt$Date, dt$Time))
dt <- dt[, c(9, 3:8)]
dt$Atr <- ATR(dt[, c(3:5)], n = 20)[,2]
### Avoid divide zero errors.
dt <- dt[complete.cases(dt),]
### MFE
mfe <- sapply(1:tw, function(x)
ifelse(sd == "B" & shift(dt$High, n=x, type = "lead") > dt$Open
, (shift(dt$High, n=x, type = "lead") - dt$Open) / dt$Atr
, ifelse(sd == "S" & shift(dt$Low, n=x, type = "lead") < dt$Open
, (dt$Open - shift(dt$Low, n=x, type = "lead"))/dt$Atr, 0)))
mfe <- apply(mfe[,1:ncol(mfe)], 2, function(x) mean(x, na.rm=TRUE))
### MAE
mae <- sapply(1:tw, function(x)
ifelse(sd == "B" & shift(dt$Low, n=x, type = "lead") < dt$Open
, (dt$Open - shift(dt$Low, n=x, type = "lead")) / dt$Atr
, ifelse(sd == "S" & shift(dt$High, n=x, type = "lead") > dt$Open
, (shift(dt$High, n=x, type = "lead") - dt$Open) / dt$Atr, 0)))
mae <- apply(mae[,1:ncol(mae)], 2, function(x) mean(x, na.rm=TRUE))
### Eratio
er <- mfe / mae
return(er)
}
```

## Summary

The e-ratio as we know it is an excellent tool for testing entry efficiency however it does have certain technical flaws. Firstly since we use the mean of MAE and MFE values, we are liable to have our results skewed by the presence of fat tails which is an inherent characteristic of the markets.

The e-ratio only gives us a slight insight into the expected volatility our position is likely to incur. Since e-ratio leaves us with a series of results per trade it doesn’t give us an overall entry trend score, i.e. how did our entry score through time. We are not shown a lot of information as to how our entry has behaved compared to the kind of information a linear regression would provide.

In a future blog post I will show what I consider to be a better method of scoring entries along with how this can be coded.