Strategy & Indicator

Signifigance Testing

I recently had someone from Portugal approach me with an Expert Advisor that he programmed. He felt that it was successful and wanted to get my opinion on its viability. I only know a small amount of information about the system, yet I was able to confidently reject it as unproven.

Statistics are the key. It provides a relatively straightforward toolbox to easily dismiss the simplest of systems. The measure in particular that I care about is called a student’s t-test.

Let’s first talk about when this test is appropriate. If you have fixed take profits and stop losses in place on 100% of all trades, then it is appropriate to use this test. The reason is that these values provide fixed limits on the outcome of trades. The distribution of your trades is likely to form a nice bell curve. In math terms, this is called a Gaussian distribution.

If your strategy uses dynamic exits based on market conditions, then this test is not appropriate. The distribution of forex, stock and futures prices do not follow a bell curve. The test depends on the assumption that the distribution under study follows a bell curve. If you make assumptions that don’t match what you’re measuring, then results are useless at best and dangerously misleading at worst.

If you’d like to go into the mathematics involved, then you can find numerous sources on the internet that explain t-tests. I also really enjoy the book Statistics by Freedman, Pisani and Purves.

Most trading systems do not follow bell curves, which makes the details of the t-test largely irrelevant. What’s useful about it is to show that you can generally feel better about the outcomes and predictions based on the number of results in the backtest.

Restrictions and Degrees of Freedoms

The goal of any test is to ensure that the results are accurate. The more frequently that you test a concept, the more confident that you feel about the outcome repeating itself consistently. The idea of predictability largely matches our intuitive expectations. If my co-worker shows up on time regularly, then I feel confident about him showing up on time tomorrow. If he shows up late regularly, then I know that he’s likely to show up late in the future.

The increase in experience increases the level of confidence. Eventually, the number gets so big that we feel very comfortable with the probabilities.

The Portuguese client presented a system based on moving averages with 3 filters, a stop loss and a take profit. Let’s assume that each filter only had one parameter. The number of restrictions for the buy trade is the moving average period (1), the one parameter for each of the three filters (3), the stop loss distance (1) and the take profit distance (1). This yields a total of 6 restrictions for buy trades. Assuming that sell trades use the same inputs, then we have a total of 12 restrictions.

We can’t begin counting our total number of trades (i.e., degrees of freedom) until the backtest shows at least 12 trades to account for our restrictions. It’s a good idea to not infer anything about a trading system until 30+ trades elapse. With the 12 restrictions in place, that sets the threshold for the minimum number of trades to reach a conclusion at 30 + 12 = 42.

Generally, it’s a good idea to see 300-400 trades before drawing conclusions about any system. The reason for this is that some events are very rare. They may only occur once every couple of hundred trials. Allowing the amount of information to approach this threshold allows the trader to more comfortably evaluate what hidden risks may be present.

The backtest that the Portuguese individual submitted only contained 27 trades. Knowing what we know about basic analysis, I comfortably decided that there is nowhere near enough information on the system to consider evaluating it.

A Word of Caution

An algorithm’s trading statistics are almost certain to change with time. Unless you have a mathematically sophisticated model for evaluating volatility, best practice demands that you evaluate the trading results in light of the type of volatility experienced. Making money in 2008 when the markets nose dived does not mean that you would have made money in 2010, which was much quieter in comparison. Any signal in 2008 that indicated a short would almost certainly show returns that include a handful of monster winners. If those monsters fail to show up because the volatility does not cooperate, then your expert advisor will more than likely flop.

Martingale Forex

Trading forex with a Martingale money management system will almost inevitably lead to blowing up an account. I’ve written about this inevitable outcomes repeatedly over the past six months. At the risk of beating a dead horse, I figured that visual proof would alleviate any lingering hopes once and for all.

Recall that Martingale systems aim to never lose money. Instead of accepting losses and moving on, a Martingale betting strategy doubles the previous bet. Whenever a win finally does occur, all losses up until that point are wiped out. The trade also gains the same amount of profit that the original trade hoped to capture.

The experiment assumes that the trader uses fixed fractional money management set at 1% of the account value. Recall from earlier experiments that a 1% risk value will almost never blow up an account after 200 trades. The percent accuracy for the trades remains at 50%, which is perfectly random. The random number file has been upgraded to include 10 million random numbers instead of the previous half a million.

The goal of the exercise is to focus on the risk of ruin rather than the profits accrued. As time goes on, the likelihood of ruin increases with the number of trades placed. A trade is each time a new transaction enters. It does not matter whether or not the last trade was a winner or a loser.

Fifty trades on most Martingale systems corresponds to anything from several days to several weeks. The level of aggression used in the trade level (i.e., the pip distance used to open a new trade) is what most strongly affects the amount of time required to reach fifty trades.

Placing 50 trades shows what most traders know. The returns look fairly nice at that point. A return of 20% on the account shows a 40% probability of occurring. The risk of wiping out the account looks meek at 8.5%.

Increasing the number of trades to 200, which corresponds to several weeks or months, the odds of outright failure skyrocket to 35%. The lucky traders that have not yet blown up show returns ranging from 20% all the way to 300%. The total risk is more apparent, although many traders fall victim to the lure of quick, large returns.  If it all looks too easy at this point in time, that’s because it is.

Going out to 1,000 trades, which I roughly ballpark as the amount of trades an average expert advisor might complete in 9 months to a year, is where the inevitable result is obvious. The odds of reaching a zero balance reach 95%.  A tiny handful of traders are floating huge returns. As the number of trades increases from 1,000 to 2,000 to 10,000, the tiny fraction of accounts left eventually dwindles down to zero.

3 Forex System Tips

Many systems nowadays promise profits without effort and easy pips right to your account. You probably know by now that real life doesn’t work that way. A genuinely profitable system is hard to come by. In this article I will describe three simple tips that help you enhance your existing trading systems. The goal is to make them more powerful and accurate.

Stop and Limit Entries to Catch Trends

Many trading systems use market orders to enter and exit the market. Market orders frequently exhibit low entry efficiencies. They get you in the market at a price that is not optimal. Placing a buy or sell order 10 pips from the price you wish to enter, in the direction of the trend for trending systems can make a big difference. For long trades put a buy order 10 pips higher than price, and for short trades put a sell order 10 pips lower than price. Range trading systems might consider limit entries, which would place the orders in the opposite direction of the example above.

Using ATR to Account for Volatility

Many novice system designers use constant pip distances in their forex trading system, i.e. 15 pips for stop loss, 10 pips for take profit, etc. This is a mistake as it doesn’t take into account changes in volatility. If the pair you trade exhibits changes in volatility, the system faces an increased likelihood of failure.

The Average True Range indicator (a.k.a. ATR) gives the average range of a forex pair or stock, and accounts for gaps as well. Instead of using constant numbers, use a percentage of ATR such as 50% ATR or 30% ATR. Once you do this change your system will automatically take into account volatility and will become much more flexible. Such systems will work better and will maintain profitability even in changing market environments.

Avoid Overoptimization

This is a tip especially for the programmers of you: over-optimization is the kiss of death of a trading system. Over-optimization, a.k.a. as curve fitting, means that you add many Forex indicators and filters and use them all to confirm your signals, and optimize them all for maximum profits. In the backtest it will seem that your system is becoming better when in fact it will become good only for the past and will fail in any forward-test on real, live data. Therefore, it is crucial to only include the most important parts of your system and do not add indicators that don’t make sense at the price-action level. Remember the principle of Occam’s razor: “The simplest solution is usually the most efficient one”.

Michael Wells is an FX programmer and trader. His site contains his insights about Forex trading systems.

Money Management Modeling

We recently developed software to model the affects of random chance on money management. Although computers are capable of generating pseudo-random numbers, the pseudo-random process introduces bias into the random distribution.

We opted to source our random numbers from random.org. The web site generates purely random streams of bits taken from atmospheric noise. We then use binary mathematics to change those bits into numbers ranging from 1-10,000.  Say, for example, that we want to model a trading system with a winning percentage of 50%.  Whenever a number comes out between 1-5,000, we consider that a winner. Anything above 5,000 marks a loser.

Changing the winning percentage to 65% works the same way. Any number less than 6,500 represents a winning trade. Numbers above 6,500 signal a loss. The modeling quality is accurate to the thousandth decimal place.  That type of accuracy is way more accurate than the “known” accuracy of your trading system, which can only be known within a few whole percentage points.

Most traders fall into the trap of thinking about their trades as individual outcomes. The more appropriate way to view returns is as the sum of all individual outcomes. Losing on any given trade does not matter. It only matters whether the sum of all your winners is greater than all of the losers.

It gets more complicated, unfortunately. A system with 50% wins and a 1:1 payout will almost never come out at exactly breakeven. The mathematical expectation is that we expect to see a degree of drift in the returns solely due to random chance. I suggest reading more in the random trade outcomes and dollar profits section to get a better understanding of drift.

Lastly, we must define a sampling period for evaluating the final result. I arbitrarily set the default value to 200. That means that the software tells us the range of outcomes after 200 total trades. That may take more than a year for some traders. Daytraders may reach that benchmark in several weeks of trading.  The question that we are answering is “what is my account balance likely to be after placing 200 trades?”

Coin Toss Trading Experiment

The first experiment is to analyze how dollar returns vary with a coin toss game and the most basic money management method. A starting balance of $100,000 is used with a risk of 1%. The risk will not change as in the fixed fractional method. Instead, we will leave the lots fixed in order to strictly understand random chance. Wins always earn $1,000. Losses always lose $1,000. The odds of a coin toss are 50% wins with 50% losses and a 1:1 reward risk ratio.

The average trade comes out to $99,868.36, almost exactly $100,000. It’s what we expect for a 50-50 game with a 1:1 reward risk ratio. What I find interesting is the standard deviation of $14,377 and how it changes. I don’t want to cover scary math topics. The layman’s explanation is that the standard deviation is the “normal” range from the average that you might expect. The $100,000 balance, in most cases, would either lose $14,000 or make $14,000.

Everything beyond those standard deviation boundaries represent the less likely wild scenarios. The minimum outcome comes out to $58,o00, a massive 42% loss. This had a 0.54% chance of occuring. The maximum outcome shows as $158,000, a monster 58% return. This had an even smaller chance of occurring, only 0.1% (1 in every 1,000 trials).

Changing the account risk dramatically affects the standard deviation. 1% strikes most traders as sane and reasonable. Yet, there is a small chance of losing half the account to drawdown strictly because of terrible luck. Decreasing the overall risk by a fourth to 0.25%  drops the standard deviation by exactly one fourth.  The worst case scenario shrinks to a highly tolerable $11,500 drawdown (11.5%). Most traders would find a number between 10%-20% reasonable. The consequence of the reduced risk is that the best case scenario drops correspondingly down to a 14.5% gain.

Stretching the risk out to 2%, a normal industry practice, turns out to be risking accounting suicide with the coin toss game.  The worst case scenario drops the final account balance down to $8,000, a staggering 92% loss.

The goal is to help you define risk from a gut feeling matter into something more tangible and calculated. Too many traders enter the market day dreaming about profits. Risk enters the picture, but too few traders actually understand the relationship between risk and reward.  Hopefully, the picture of best, worst and average scenarios is starting to become more clear for you.

Forex VPS

Automated traders frequently ask my opinion on VPS hosting and trading. Although I’ve written about this in the past, I’ll say it again: if you’re trading any kind of serious money, then you need to run your strategy from a data center. They come with backup everything. The connections are redundant, the power supply is redundant, etc. Plus, they have a full time tech team sitting around waiting for something to break so they can fix it. It’s definitely in your best interest.

I always refer clients to TradersColo for forex VPS hosting. Nash Waddud is a former colleague from my time at FXCM. I know him personally from working together in their Dallas office. He’s an upstanding guy that works very hard to take care of his customers. The prices are also right in line with industry standards.

I rented a VPS from him for testing software last month. The data center was unable to open a port that we needed, making the VPS unusable as a testing environment. Instead of walking away with the $25 hosting fee, Nash offered a full refund. I never asked for it. He just offered it up. That’s the kind of person that I’m happy to refer my customers to.

All of the hosting plans are sufficient for running generic expert advisors. If you’re unsure which plan to use, I recommend calling Nash directly. He can help you pick the appropriate package.

Toxic Trade Flow in Forex

I work with a number of expert advisor vendors and CTAs that want to sell their products. Whenever they approach a forex brokerage about partnerships, the inevitable first question the broker asks is, “Is the trade flow toxic?”.

Not all expert advisors are cut from the same cloth. Many trade infrequently. Strategies that trend trade or that trade long term ranges are broker favorites. The flow is predictable. The brokerage’s order book does not shift quickly.

Many large brokerages today still run dealing desks. When an order comes in to buy EUR/USD, the broker acts as counter-party to the trade. The customer is long and the brokerage is now short. Dealing desks handle this situation differently depending on their market perspective. If they do not have an opinion on market direction, then they will simply offset their trade by going long with their liquidity provider, which is usually a top-tier or group of top-tier banks. That relieves the broker of his exposure. He also keeps the mark up in the spread or commission for his efforts.

When the broker expects the market to move a certain direction, the dealing desk may elect to maintain the exposure. The trader’s loss is the broker’s profit and vice versa. The dealing desk wants to ensure that it is not overleveraged, but also to ensure that it maintains the desired level of exposure (say, for example, 100 standard lots long EURUSD). Traders that shift their positions rapidly force the dealing desk to constantly and quickly update its own position size.

Brokers with market positions hate scalping EAs. Trades that enter and exit quickly interfere with the broker’s goal of maintaining a position of a certain size. The amount of work required to maintain the exposure generally does not offset the amount of profit earned from the scalping trader. It’s business they don’t want. The industry term for unwanted business is toxic order flow or toxic trade flow.

Toxic orders and low liquidity

Another other kind of toxic expert advisor is one that takes advantage of price movements stemming from low liquidity. FAP Turbo is most infamous of this type. Whenever the price of EURGBP or EURCHF spiked quickly, the FAP Turbo expert advisor attempted to enter quickly on the movement. More often than not, the price quickly retraced to the take profit level of 3-5 pips.

Traders loved it. It was the closest thing to near instant profit. Brokers, on the other hand, despised FAP Turbo. Most brokers don’t care if individual traders make money off of them. When 10% of their customer base earns off of them and does so all at the same time, it’s a massive problem. The order flow was toxic to their businesses or to those of their liquidity providers.

The EURGBP typically offers market depth of 2-3 million euros, which is a pittance compared to the majors. Now consider that there were several thousand FAP Turbo users at the height of its popularity. Although most only traded mini lots, a substantial portion of them traded standard lots. Think about the combined order size of 2,000 traders while there is only 3 million available in liquidity. It just doesn’t work. There are too many dogs chasing a single piece of meat. The first ones to get their orders across got filled, but the back of the pack gets stuck either with scraps or nothing at all.

The traders that did win get on the brokers’ nerves for two reasons. It’s not that the traders won. It’s that they won and it only took them seconds to do so. Brokerages that offset their risk do not have sufficient time to do so. Brokerages that don’t offset their risk do not have sufficient time to enjoy the exposure that they are after.

The liquidity providers that filled the first wave of orders are not happy, either. This is probably the biggest problem of all. All forex brokerages rely on the dealing desks of major banks (i.e., liquidity providers) to some degree. There are only 10-15 major banks worth dealing with. It’s a small, almost incestuous community. If you get a bad name with one of them, you get a bad name with all of them.

The liquidity providers go back to the brokerages and dictate that they either shut out the toxic order flow or threaten to sever the liquidity relationship.  When the choice is between a critical supplier or a single customer, it’s always the customer that gets the boot.

Breakeven Trailing Stop

The trailing stop that we build in most of our custom expert advisors varies somewhat from the generic trailing stops out there. The code uses two inputs. An input is basically a variable that pops up on the screen when you load the expert advisor. You can change the input value without the need for additional programming.

Expert Advisor inputs tab

This is a screenshot of typical inputs for a MetaTrader expert advisor

The unique aspect of our trailing stop is that it does not trail until the trade reaches a certain amount of profit. Delaying the adjustment allows the user to treat the stop order as a take profit tool instead of simply exiting at a loss.  Most traders feel that once a runner appears, only then does it make sense to adjust the initial rules for exiting at a loss. Acting defensively about the trade only when a decent amount of profit is on the table avoids early stop outs, or at least so the theory goes.

TrailStart is the input which controls when the stop moves from losing to breakeven. It is only at this point of profit that the EA adjusts the exit conditions to avoid a loss.

Say, for example, that the TrailStart is set to activate at 20 pips. That means when your buy trade goes up 20 pips from the entry price, the EA automatically adjusts the stop loss to equal the entry price. The EA cannot lose from that point forward, not counting the effects of slippage.

TrailAmount kicks in only after the stop already adjusted to breakeven. This input controls the distance to increments at which the stop loss should update favorably. If TrailAmount equals 5, it means that the stop loss should adjust in your favor 5 pips for every 5 pips of extra profit beyond the TrailStart at 20 pips.

If the stop loss already moved to breakeven at 20 pips, it means that the stop loss is currently at 0 pips. The trade neither wins nor loses if the market hits the stop. If the price advances another 5 pips (TrailAmount ), the expert advisor determines that it must trail the stop again by 5 pips. The price reaching +25 causes the stop to advance from 0 to +5. When the price moves another 5 pips to +30, the stop advances to +10.

Notice how the stop distance remains a consistent 20 pips in the example. It’s the exact same amount as the TrailStart input.

Random Trailing Limit

I got the idea for a trailing limit from Van Tharpe’s market classic Trade Your Way to Financial Freedom.  I made Jon Rackley read through the book as part of his training when I first hired him. He brought my attention to an unusual claim made on page 267. Van Tharpe says that it’s often possible to make money even with random numbers.

Random numbers are a pet theory of mine. I’ve long put effort into figuring out whether I could develop a strategy that trades totally at random and still makes money. As the owner of a programming company for traders, and as part of Jon’s initial training for NinjaTrader in December, I assigned him the task of programming the strategy into code.

The book states that trading with totally random entries and a 3 ATR trailing stop generally leads to making money. Flip a coin. You go long if it lands on heads.  Go short if it lands on tails. One important note is that we elected to use pure random numbers in our programming instead of the pseudo-random numbers that computers generate. Doing so allows us to avoid time biases in the seeding process that generally pop up when the seeds used are close together in time.

The first working version that I reviewed displayed everything contrary to Van Tharpe’s claims. Using a trailing stop, regardless of the instrument and time frame tested, inevitably led to devastating losses. The profit factors consistently came in near 0.7, a truly awful number.

We did what most of our clients do when they find abysmal strategies. We flipped the strategy on its head. The new strategy uses only a 3 ATR (50 period) trailing limit.

Trailing Limit Analysis

The early conclusion is that trailing limits seem to offer a great deal of potential. Although Jon sent me the code several months ago, it’s only this evening that I had a chance to properly review and test everything.

The profit factors are very encouraging. It depends on the chart that I tested. The worst that I found was a 1.0 profit factor. Everything else came out with profit factors greater than 1. The small table below contains the initial test results. Before you go off salivating that this is the next hot winner, there are a few considerations to keep in mind:

  1. The results depend entirely on the sequence of random numbers used. Using different sets of random numbers will cause different outcomes.
  2. The better results on the higher time frames likely result from sampling error. The number of trades involved was only ~160, which is not enough to make definitive conclusions on the nature of the performance. I prefer to see 400 or more trades before drawing definitive conclusions.
  3. These results do not include spread costs or commissions.
Currency Period Profit Factor Dates Tested
EURUSD M1 1.12 9/12/2011-3/12/2012
GBPUSD M1 1.16 9/12/2011-3/12/2012
USDJPY M1 1.25 9/12/2011-3/12/2012
EURUSD M5 1.11 2011
GBPUSD M5 1.0 2011
USDJPY M5 1.06 2011
EURUSD H1 1.26 2011
GBPUSD H1 1.25 2011
USDJPY H1 1.48 2011

Random trades sometimes produce solid looking equity curves

Random trades sometimes produce solid looking equity curves. Remember that this was generated with purely random numbers and a trailing limit

What made me feel better about the results was reviewing the entry and exit efficiencies of each strategy. The number of trades involved really cluttered the graphic. I ran a backtest on a much shorter time period so that the horizontal, blue line would appear clearly on each graph.

The entry efficiency of a random entry is... random

The entry efficiency of a random entry is... random (45.45% entry efficiency)

The exit efficiencies of random entries with traililng limits are outstanding

The exit efficiencies of random entries with trailing limits is off the charts. (77.73% exit efficiency)

The entry efficiency tells us exactly what we would expect to find. Trades which enter at random do not perform better than random (obviously). What’s interesting is how the trailing limit exit strategy actually skews the entry efficiencies to read slightly worse than random. This is a good example of why it’s dangerous to rely purely on statistics. Keeping the big picture in mind reduces the likelihood of making an erroneous conclusion, in this case that there might be something “wrong” with our perfectly random entries.

The exit strategy, which is what we’re truly testing, looks absolutely stellar. It shows that acting as a conditional probability allows for a great deal of adverse movement while capturing extreme points of the move.

Adding Money Management

The percentage of winners for the tested charts ranges from 60-67% accuracy. High percentages of winners often lead to winning streaks. My cursory glance through the chart led to my easily finding a suitable example to cherry pick. Here, 5 trades in a row reach their near maximum take profits.

Random trades on a hot streak

Picking trades at random occasionally leads to streaks of lucky winners

Testing that I’ve done in the past tells me that it’s often advantageous to increase the position size based on consecutive winners when a strategy is more than 50% accurate.  My first idea after reviewing the initial results was to modify the forex money management strategy to pursue the consecutive winners. We unfortunately do not have time to pursue those changes in the code right now. Let me know if you’re interested in seeing this and we’ll make it a priority if enough readers respond.

While increasing the risk after consecutive winners works out statistically in your favor, it does add to the risk. It’s entirely possible for a “winning” set of trades to start losing based solely on the money management strategy.  There’s no way to know whether your set of trades will be the luck beneficiary of the extra risk or whether it will be the unlikely loser.

Conclusion

Everyone talks about stops. You always have to have a stop. Blah blah blah. I know it’s going to be the first question that everyone asks.

My research shows that trading with a stop is for suckers. Larry Connors’ book Short Term Trading Strategies That Work was the first trading book where I actually felt like I read valuable information. One of my favorite sections is on stop losses. His research shows that using a stop loss (even a 50% stop loss) always reduces the performance of a strategy. My own independent analysis bears this out.

Not using stops does not mean never taking losses. On the contrary, refusing to exit the market at a loss makes for a 100% odds of blowing up one day. The point of using a stop or limit is to empirically define, and to never waver from, a specific point or points in the market at which you will exit. A trailing limit accomplishes that goal admirably.

Interestingly, the trailing limit is one feature which FAP Turbo incorporates that I have yet to find in any other expert advisors. Although I’m not a fan of FAP Turbo type of strategies, it certainly does interest me that one of its main features aligns with this research. Also notable is the fact that the trailing limit continues down even to the point where it accepts losses.

Range Trade at High Frequency

Range trading systems make the best candidates for high frequency systems. They are less execution sensitive than trending systems for a simple reason. Range trades “catch the falling knife,” making them suitable for using limit orders.

High frequency prices vary from the normal M30 and H1 charts. The lower the time frame, the better that the chart fits to a normal bell curve. One common theme in systems trading since the 2008 crash has been “tail risk” or “fat tails”, which refer to the edges of a probability distribution like the bell curve. The fatter the tails, the more likely that a range trading system is to crash and burn.

The high frequency bell curve shows the tail risk of important events

The bell curve shows the tail risk of important events. The tails are colored in red. Fat tails mean that important news happens more frequently

The real world events captured in the tails reflect headline news like Bernanke speaking or Ireland announcing another referendum on all this bailout nonsense. The events only happen once, obviously. If you consider the news events in the context of hourly charts, they happen frequently as a percentage of the overall period. If you look at a one minute chart, that same event is now about 1/60th as important. Dropping down to tick charts nearly makes the events disappear in the statistical profile.

My experience is that the news cycle drives trends on a macro basis. “Macro basis” and high frequency are two topics that don’t belong together. Trending systems should focus on long term trading, while ranging systems are far more suited to high frequency. If your system trend trades, you can throw it in the rubbish bin for high frequency trading ideas.

High frequency considerations

Keep in mind that there are effectively two ways to participate in the forex market: you can either act as a price taker or as a price marker. Price takers range across all market participants. A hedge fund or university endowment is just as likely to take a price as they are to make one. CTAs and retail forex traders are much more likely to make their decisions based on the expected market direction. Timing is critical for them, so they don’t want to leave it to chance whether or not they’ll get to enter a trade.

The trader gets filled right away. That’s the major advantage. The main disadvantage to acting as a price taker is that you pay the spread every single time that you want to enter a position.

I sat with AvaFX in Dublin on my last trip. They charge a 3 pip fixed cost spread. I mentioned my concern about how that spread affects my client’s EA performance. His MetaTrader expert advisor trades 4 times per day on 2 currency pairs. If you do the math on a 3 pip spread, it works out to 8 * 260 = 2,080 trades per year. If you’re paying 3 pips and trading a $10,00 account, you would have to earn $6,240 per year – a 62.4% return, just to cover trading costs. I don’t care how good a system is – it will never cover those kinds of costs. Trading on margin will not do anything to resolve the issue. Spread costs are directly proportional to the amount traded, which impacts the profit. There is no way to trade and make money if the transaction costs are too high.

Designing an expert advisor is difficult enough, but it’s even harder when you factor in the trading costs. Say, for example, that I develop a EA that wins 75% of the time with a payout of 0.5:1 before trading costs. When the EA wins, it earns $0.5. It loses $1 whenever a loss occurs. The profit is 75 wins * $0.5 = $37.5. The loss is 25 * $1 = $25. The expert advisor’s profit factor is 37.5/25 = 1.5.

That should sound great. The problem occurs when the total commission outweighs the total expected profit. This example required 100 trades. Let’s say that we were trading mini lots with an average win of 5 pips and the average loss of 10 pips. That puts the gross profit at $375 and the gross loss at $250. The return is $125 for the 100 trades, excpet that we must now subtract the $100 for trading costs. The total profit plummets to a measly $25.

If the expert advisor’s expectations held true for something like a 10 pip take profit and 20 pip stop loss, the trader might be better off to change the exit points. The reason is that the profitability may actually improve. The goal would be to reduce the number of trading opportunities with an eye towards making them more profitable relative to the costs.

A better approach, in my opinion, would be to switch over to market making. Although you usually still pay to trade, the advantage to market making is that you earn the spread rather than paying it. The spread is overwhelmingly most traders biggest cost. Not paying it opens the possibility of applying the strategy where one normally could not afford it.

Market making only works if your forex broker allows you to post best bid/best offer and have the price reflected on the screen. Most brokers claim that they are ECNs. A real forex ECN allows you to post limit orders. Whenever that order represents the best bid or offer, the price and size of your order shows up on the screen. The only retail trader friendly brokers that I know of are Interactive Brokers and MB Trading.

I ran my NinjaTrader license at MB Trading last week to test the execution and order flow. The test only use traded a microlot (0.01) and posted best bid or best offer on the EURUSD. The orders remained valid for anywhere from 1-10 minutes. Despite the small trade size and lengthy time period as best bid/offer, the orders only filled 75% of the time. That meant that I caught 100% of the losers but only 56% of the potential winners. Not good, in spite of getting paid for the limit orders.

Interactive Brokers is the next test candidate. They have been around much longer and should have far more order flow. I’m hoping that the low fill rate that I experienced making a market at MB Trading will improve substantially when I shift the same strategy to Interactive Brokers.

I expect to find a few other changes as well. The spread that I earn should fall from around 0.9 pips on EURUSD to 0.5 pips, which is indicative of Interactive Brokers’ improved pricing. I also will have to pay a 0.2 pip commission, which reduces the net credit from 1.0 pips at MB Trading (0.9 spread + 0.1 commission) to 0.3. Nonetheless, I expect the improved fill rate on winning trades to work more in my favor.

The thing that most people will hate is that you can only test a market making approach with live money. It’s sufficient to backtest a strategy using market orders with a 0 spread assumption. The goal is to weed out the junk from diamonds in the rough. No method exists, however, to accurately determine whether or not a trade would have gotten filled with a limit order. The only way to find out is to test an idea with live money, then to compare the results to a backtest over the same period. If the live, high frequency performance is similar to a backtest, then you probably have a winning approach.

The real motivation here is to get as many opportunities as possible. Just like the casino does everything to help you pull the slot machine faster, the trader should look for as many favorable setups as possible. High frequency stands out in this area. The inherent advantages of a system are more likely to manifest more quickly. Assuming that you get a handle on the trading cost problem, the profit is often limited only by the number of trades that can be squeezed into a day.

Programming options at high frequency

MetaTrader 4 is not a good candidate unless you expect to post orders once per minute or slower. MetaTrader suffers from the Trade Context is Busy error. Running an expert advisor on more than a single instrument could cause orders to enter too slowly or not at all. MetaTrader is only an option with MB Trading. Interactive Brokers does not support MetaTrader.

NinjaTrader works great and offers a lot of the broker portability that comes with programming in MQL. Programming a high frequency strategy in NinjaTrader works at most human speeds (5 seconds or more). For the brokerages where NinjaTrader submits orders using the broker’s API, I find a speed bump affect at work. NinjaTrader processes the orders lightning fast, but the broker API cannot handle the speed and starts to choke. If you want to test any frequency that’s not ultra high frequency, I recommend programming in NinjaTrader.

The FIX Protocol is the best option for the institutional trader that cares about maximal performance and does not suffer from the usual budget constraints. FIX is a fancy way of controlling communications between a custom platform and the broker. It does not involve software, only rules. The FIX protocol allows the trader to write software 100% from scratch. The trades and orders can go out the door literally as fast the machine can process them. It’s the advantage that comes with building everything from scratch.

Sign up for EA Package


* = required field

powered by MailChimp!