Forex

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.

Magic number in MetaTrader

The magic number is a Metatrader concept used to track the open positions of an EA. The concept allows the Ea to distinguish the trades that it opened versus those that it did not.

Each car uses a license plate. When you detect a car in a different state or even a different country, you observer that every plate that you come across is unique. Law enforcement can utitlize the number to determine who owns the car.

Magic numbers function like the license plates for expert advisors. When an expert advisor detects an open trade, called a ticket, it repeatedly asks for its magic number. If the magic number of the ticket is identical to the number that the expert advisor expects, then it knows to manage the position.

Magic numbers are helpful, particularly when you want to trade multiple time frames of the same forex pair. Traders often use settings that differ from those on M1 prices versus those that they would use on the daily chart. If they used the Expert advisor with the same magic number on all different time frames, the result would be chaos. The expert advisor would open and close positions with no rhyme or reason. Setting every Expert advisor to emply an unique magic number disallows the robots from interfering with the others.

Magic number factoids

The magic number of a manually opened trade is 0.
The number that you use for a magic number must be a number ranging from 0 and 2147483647. The MQL programming language assigns that last number EMPTY_VALUE and protects the name as an integer value.

OneStepRemoved.com is a company that specializes in programming an expert advisor for traders. Shaun Overton is the company owner.

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.

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.

Market Depth

Moving from small time retail forex accounts to a serious account size comes with some bumps in the road. Most traders see the prices of forex pairs on the screen and assume that they can buy and sell unlimited quantities at any time. Although the forex market is the largest market of any in the world, making it the most liquid, there is still a limited size to what you can trade at any moment.

Reading Forex Market Depth

NinjaTrader and MB Trading both make market depth information available in their trading screens. It shows where all of the nearby liquidity lies. Say, for example, that you wanted to place a big order for EUR/USD. You can see in the screenshot from MB Trading’s platform that the liquidity gets bigger as you get further from the price. They call these “Level 2″ quotes, which is jargon taken from equities traders.

Market depth of EUR/USD

MB Trading's Navigator shows the market depth of the EUR/USD. Light colors show the best prices, darker prices indicate distance from the best price.

I took this screenshot in the late afternoon when liquidity is at its worst. The best bid shows a depth of 200, which is measured in mini lots of 10,000. You could sell up to 2 million EUR/USD and get filled at that price. Notice, however, that most of the liquidity is further away. 3 million sits at the next best price and another 3 million even further from that. The net available liquidity is 8 million on the short side and 6 million on the long side for a total of 14 million.

The FX Pro screen in NinjaTrader makes it even clearer. I took this screenshot several minutes later, which is why liquidity numbers are different. One thing I really like about this screen is that NinjaTrader converts the liquidity depth into more tangible numbers. The formatting makes more sense to me. Plus, it’s much easier to keep track of the varying spread.

FX Pro screen in NinjaTrader

The FX Pro screen in NinjaTrader

What you learned in economics doesn’t apply to trading. Dealing in bulk actually leads to worse pricing instead of improved pricing. The reason is that forex instruments are so standardized that there’s effectively never a lack of customers. It’s really an issue of getting how much much you want at a certain speed.

Only a fool would hit the market with 20M EURUSD instantaneously unless you’re desperate to exit a position. If you push a market order judging solely from the quote on the screen, you may get 2-8 million filled at the displayed price. But, the rest of the order will get filled at progressively worse prices. The traders making a market want their pound of flesh for letting someone into the market so quickly.

Traders cannot see the liquidity depth of most brokers because they elect not to show it. Their platforms encourage the buy this, buy that psychology. The more information that they broadcast, the more bandwidth that’s required, which means that better servers are required.

The EURUSD is the most liquid forex pair in the world. This varies largely by broker, but at any given time you should be able to trade 20-30 million EUR/USD. That doesn’t mean that you’ll get filled at the price on the screen. What that means is that that is the sum quantity available at any given moment.

Some brokers hide their quantity. It’s not like the stock market where if there are 15,000 shares of Microsoft ready to trade at any given moment, you can see 100% of the liquidity available. In forex, as an OTC market, the broker may wish to restrict the viewable book for a few reasons.

If you offer markets from say 5 banks, it’s very rare for the broker to feed the best competitive price and to let the banks fight it out? Why? Because the broker also needs the banks to stick around when nobody wants to trade.

It’s an informal agreement that if I’m retail broker A and UBS is my main liquidity feed, I go out of my way to give UBS the good flow. My customers expect to trade during NFP and other volatile markets (although they really shouldn’t!). If the brokerage simply lets the banks fight it out, then the banks have every reason to let the brokerage rot on the vine when their customers want to trade but it’s bad for the banks. The banks certainly don’t want to take positions in volatile markets. Their only incentive for doing so is if the “good flow” that the forex broker sends during normal markets incentivizes them to accept the risk of losing more than they care to during NFP.

News traders are the most likely to try trading during a thin market. They are also the most likely to complain about not being able to trade. These are the arguments to which I’m least sympathetic. If you’re trading the news, you are overwhelmingly likely to have less than one year of trading experience. The decision has nothing to do with researching systems or evaluating whether or not it’s a good idea. It has everything to do with gambling.

Retail traders are the most likely to trade during volatile events, not just news but really any type of momentum. Almost everyone follows a breakout or momentum strategy. It has everything to do with what traders perceive as the most likely outcome. When the market explodes in one direction, it takes nerves of steel to stand in front of the freight train. Therefore, it’s probably a good idea because it’s counter-intuitive.

Trends happen so slowly that they don’t excite the gambling buzz that most retail forex traders are after. My friend Afshin in Dublin fell victim to this last week. He saw the EUR/USD rising day after day after day. He felt like it was simply overdue for a correction. The urge to participate, rather than coming from a desire for a quick hit, instead came from a desire to be right before there was any clear indication of the opportunity to be right. The point is that what feels natural to do is often precisely the wrong thing to do. It feels natural to every other trader, too.

Market Depth and Direction

One research project that I’d eventually love to do is to study how market depth on any given side of a market affects direction. Some traders run simple liquidity businesses where they receive trading rebates in exchange for accepting the risk of holding a position over the short run. These entities are less likely to concern themselves with picking the direction of the market.

Trading desks that make markets, however, often want the flow so that they can establish a position and earn the spread while doing so. These entities are picking direction – and they are backed by very intelligent math geeks with PhDs and a lot of time on their hands. If those desks make a visibly deep market and it’s sufficiently one sided, then it’s probably safe to assume that they expect to the market to move in the opposite direction.

When you’re buying a forex pair, the bank is selling it to you. So if everyone stacks the liquidity so that you can buy but the liquidity is thin on the short side, it should be telling you that the smart money wants to go short right now.

High Frequency Forex Seminar

One exciting opportunity popped up while I’m in Dublin next week. Best of all, it’s free and open to the public. If you’re in the neighborhood and would like to discuss trading in person, I’d love to meet you.

Trinity College Dublin invited me to present a graduate level seminar to MSc students in Finance and Alternative Investments on Wednesday, February 8, at 6 pm. The seminar will be hosted in the MBA room, which is on the second floor of the business school. The topic will be high frequency market making in forex.

Topics for the high frequency forex trading seminar (about 10 minutes per subject):

  • Market making versus price taking
  • Comparing frequency to expectation. The more you trade, the more you make
  • Liquidity risks and self-feedback loops
  • Technical approaches and limitations

Donchian Channel

A Donchian channel measures the highs and lows of the price over a certain period in time. A lot of traders use this concept in their trading, although they are not familiar with the name Donchian.

Most Donchian channel expert advisors attempt to catch breakouts. I almost never see people use it with a ranging approach. Most traders want to ride the excitement of an ever-increasing market. The price, especially with the forex majors, often strikes the previous high or low. The price surges for a minute, only to retrace to well within the previous channel.

The hazard of using Donchian channels as breakout strategies is if you jump too early, you risk making a big fuss over nothing. If you jump too late, then you miss the move. I have not found any method for predicting when these moves will happen. My experience with fractal markets is that the period of a new movement, big or small, is totally random. The condensed trading time and low liquidity make it extremely difficult to try catching a move as it happens, at least on an intraday basis.

I have not done any testing on this, but I suspect that a ranging approach might work better. Most momentum traders are weak hands. They only play when there’s action. As soon as the action disappears or reverses itself, they all tend to leave the party. The dominance of retail traders favors a contrarian approach.

Most traders look at similar points to decide when momentum is truly occurring. They use Donchian channels, although different traders tend to use different periods. The important take-away is that the precise price that they care about tends to vary ever-so-slightly based on the period selected. The Donchian price is more or less the same, regardless of the period.

As an example, you might choose a lookback period of 55. The Donchian channel would consist of the highest high that occurred within the past 55 bars. The high could have occurred on the 55th previous bar or 10 bars ago. Time is ignored. The channel’s low corresponds to the lowest low in 55 bars or periods.

Turtle Traders

The most famous Donchian channel method comes from Richard Dennis and his Turtle traders. Dennis and friend argued over whether good traders were made or born. As wildly successful traders, they had several million dollars at their disposal to settle the bet.

The system used the 55 period high and low to determine the entry. When today’s price strikes the highest daily high in the past 55 trading days plus one tick, the trader enters at market. The system focused on commodity futures.

Most people tend to focus on the methodology that they used to pick the market direction. The original turtles argued that their success came from the unique money management and portfolio selection methodology that they used.

As a winning trade increased in value, the Turtle Trader added a second trade to his floating winner. They used recent volatility and their own risk variable, called N, to determine how far or near the second entry should occur from the original. They would do this up to 4 times, eventually letting their massive winners ride for months.

The system worked extremely well through the 1980s. My understanding is that the performance degraded towards the end of the decade.

If you’d like to read through the entire list of the Turtle rules, I suggest that you read through the Turtle Trader PDF that’s been floating around the web for years.

Forex Money Management

The vast majority of traders obsess over the percent accuracy of their expert advisors. Intuition makes it seem like that the more often a trader wins, the greater the chances or turning a profit. Alas, such an approach ignores a critical variable.

The average win-loss ratio plays an equally vital role in determining the net outcome. I meet a lot of would be scalpers. High frequency trading is incredibly popular, but a lot of traders involved with it only do so because it puts easy points on the board. They don’t pursue a strategy because it has any positive expectation. In other words, they are gambling and not trading.

One of the reasons that I love trading so much, and why I generally dislike gambling, is that you are always in control of the potential payout and the payout ratio. When I play blackjack, I only control the risk and payout. I do not control the ratio of the payout at all. It’s always 1:1.

My decisions in blackjack can only realistically improve the odds to 50%. More than likely, my game play will lower the odds below that threshold. Making decisions repeatedly will overwhelmingly result in human error. It’s our nature.

When I open my forex account, each trade commences a new round in the game. The critical difference between trading and blackjack is that I control the ratio of the payout, plus I still control the risk and quantity of the payout. The net outcome can still move against me due to random chance. The key distinction is that the typical outcome should shift in my favor with an algorithmic trading system.

One of my favorite trading books is Van Tharp’s Trade Your Way To Financial Freedom. We’ll be talking about this one soon; it’s the next item on Jon Rackley’s reading list. One of my favorite aspects of the book is its emphasis on money management strategies and trade expectation.

The term money management connotes many things to many people. The more accurate phrase would be to describe it as a position sizing strategy. When entering a trade, you realistically need to know:

  • What is expected loss as a percentage of the account?
  • What is the expected gain as a percentage of the account?
  • What is the percent accuracy of my trades?

Answering these questions accurately leads to the decision of how many lots, contracts or shares to trade. Controlling the size leads to controlling the outcomes. When you control the outcomes, you ideally earn a profit for your efforts.

Fixed fractional money management

Notice that I said percentage of the account in the bulleted items and not the dollar value of the trade. Thinking in terms of dollars is easier on the mind. The problems is that it ignores the wonderful benefits of exponential growth.

Every financial advisor on earth warns you that compound interest, which is a form of exponential growth, is the strongest force working for you with investments or against you with debts. Applying the same concept to trading, you want to put the power of compound growth on your side.

The fixed fractional formula is an ugly way to telling you to use exponential growth in your trading strategy. Say, for example, that you elect to risk 1% of the trading account based on the distance to the stop loss. If you have a $10,000 trading account, that’s only $100 of risk. Say that the trade works out and that you made $100. The next trade should risk $101.

Try not to roll your eyes at that one. Risking an extra dollar seems trivial and nit picky. I assure you that it is not.

I’m really not sure how to explain how all those little differences add up, but they do. I wrote a money management calculator a few years back that calculated how fixed fractional money management affects returns. The little things really do add up. With a very slight probability of winning and 50:50 odds, the returns were overwhelmingly larger when using a fixed fractional approach instead of a fixed lot approach. You should increase the position size after winners and decrease the position size after losers.

Percent accuracy is half important

If I paid you $1 for every win and you win 99% of the time, should you play my game?

You don’t have enough information to make a decision yet. You need to find out what happens when you lose.

If you lose $100 or more on the trade that only loses 1 time in 100, you should never play my game. You will lose if you play too often. And no, there is no such thing as just playing ten times and stopping. You have the same risk of losing on the first trade as you do on the 100th. It’s not safe to play at all.

The only way that you should decide to play the game is if the total payout is better than even. The total result of wins equals 99 trades * $1/trade = $99. The one loss must be less than $99 to give me the green light on playing.

If I lose $80 one time and make $99 on the remaining trials, then I will have an average win loss ratio of $99/$80 = 1.24. A system like this would be wildly in my favor.

A 60% winning accuracy is a lot more likely to happen in the trading world. Let’s say that I make $100 on every winning trade. My total winning value is 60 trades (out of 100) * $100/trade = $6,000. The maximum average loss that this system could tolerate is:

The maximum average loss that we can tolerate is $6,000 / 40 trades = $150. I should consider trading this system if the average loss comes in at $149 or less. The smaller the average loss, the greater the net outcome.

Kelly formula for Forex Trading

One problem we face with money management strategies is choosing the percentage of the account to risk. The difference between risking 1% or risking 2% of the account equity is simply one of proportion. One of the options either provides a risk-reward profile suitable to the trader or it doesn’t. The larger the appetite for risk and reward, the bigger the number involved.

The Kelly formula removes the proportionality for the question and takes a different approach: how do I make the absolute largest sum of money over time using my trading statistics. The goal is to make the maximum amount of money without getting margin called.

The formula to use is K = W – (1-W)/R where:

K = percentage of capital to be put into a single trade.
W = Historical winning percentage of a trading system.
R = Historical Average Win/Loss ratio.

The approach is most suitable for those trading small accounts, perhaps those with only a few thousand dollars, that they want to grow with maximum aggression. Losing a few dollars is thoroughly unpleasant (been there, done that!), but it’s not financially devastating, either.

It’s important to keep in mind that the Kelly formula attempts to push the trading system to its absolute maximum without busting. Knowing how close it is to the edge of busting, it’s critically important that you understate the good assumptions and overstate the bad ones. Drop the expected percent accuracy by several percentage points to accommodate the chance of error. Lower the win:loss ratio for the same reason.

The easiest way to reduce error and the chance of acting too aggressively is to make sure that you calculated the EA’s percent accuracy and its win loss ratio on a large enough sample size. I would consider 100 trades as the absolute bare minimum. 300-400 is sufficient. 1,000+ trades makes for an adequate sample for most expert advisors and trading robots.

Of course, you can always take the easier approach and simply cut the Kelly formula’s risk suggestion in half. It adds a bit of scientific flair to the strategy, while minding the fact that we are human. Watching an account drop near zero will break the heart of even the most battle tested trader. It’s impossible to stop caring about drawdown, which the Kelly formula totally ignores.

Martingale Lessons

In the spring of 2011, there was no denying it.  I adopted a decidely jaded view of the stock market and had grown to despise an industry full of self proclaimed oracles.  Most of these people in my view were a bunch of textbook salesmen and women selling various dreams of financial security and fame.

Through sheer stubborness I remained invested and recovered from the down years of 2008 and 2009. However, single digit gains were taxing my patience. I was miles from my longterm goals. There was no doubt I would be working well into my 60s and if I suffered any type of dementia, it was not hard to imagine myself greeting people at Walmart.  When I stumbled upon Forex, you could say I was open to a change.

The Allure of the Martingale

Through my work as an expert advisor programmer, I became involved in coding all manner of peoples trading strategies into small trading robots called expert advisors or custom indicators.  I am still surprised by all the permutations of indicators, chart patterns, money management mechanisms, etc, that trader are dreaming up out there.

I would code them all up according to their specifications, slap them in a backtester to put them through their paces, fix any problems. Rinse and repeat until all was working to everyone’s satisfaction.  Many if not most were flawed for one reason or another, some would work exceptionally well in one type of market but perform poorly in others.

Some were tied to faulty indicators that would change their earlier output signals. Some were based on what I viewed as various arcane chart patterns which seemed one step removed (no pun intended) from witchcraft. Others were complex to the point where they would rarely trade and when they did would do so at the most inopportune time.

After perhaps a year of this, I received a Martingale strategy to code for an overseas customer.  After coding and running his EA in the strategy tester, I remember becoming very excited with how well it was performing on every time period and data set in all markets.  I spent more time testing this EA that day than most, even though I was not finding any problems with the coding.  After seeing so many crash and burn that week, I enjoyed watching it do its thing.

To be sure, it was not the first Martingale I had seen and I had always discounted that ilk as being to closely tied to Vegas and gambling. But, like the ones I had seen before, it was doing a bangup job of piling up cash during my test runs.  I guess after seeing the nth Martingale doing that I could no longer ignore this method of trading.

That afternoon and for many days following, whenever my thoughts would wander ideas would pop into my head as to what sort of Martingale I would program in MetaTrader for myself.  It was truly something of an epiphany. Up to that point my whole view of forex was that of a high stakes market best left to big banks, institutional investors, and governments.  I had never thought of running one of these programs on my own money.

Like most Martingales, mine would double its lot size with every loss.  I suppose what was different about my Martingale from many but certainly not all others, is that mine would reverse the direction of its trades.  This would solve trending markets, the achilles heal of single-direction-trade martingales.  It would also use a Take Profit and Stop Loss that would be somewhat sensitive and self-adjusting to Average True Range. This was my answer to excessive volatility.  Finally, I put in logic to have hidden take profits and stops.  This would satisfy my probably unwarranted suspicion of brokers.

I’m not going to get too detailed on leverage, margin requirements and such.  With a Martingale, you need to consider how many levels you’re going to let it go before it gives up or resets its lot size.  And don’t kid yourself; it will go deep more often then you would think.  You need to make sure you have enough money in a Martingale trading account to support your biggest possible trade.

Happy Days and Riding the Martingale bull

I went through the trouble of setting up a forex account and started trading.  The first month felt underwhelming.  I recall the EA only did a little better than breakeven but my enthusiasm was still intact.  The fact that I did not lose any money comforted me, making it feel safe to press on.

I continued tweaking the EA and adjusting how I would use it.  By the end of the 2nd month, mostly through trial an error I found the EA worked best on the EURUSD and the 15 min period. That’s when the results started to give me that euphoria that I had so badly wanted.  By the end of the fourth month, morale was sky high.

I’m not going to give actual numbers since I used to always suspect other type articles of fish tails when they did that, but it was enough to make me a changed person.  If you can recall the nursery rhyme “Sing a Song of Sixpence”.  The line “The King was in his counting house, Counting out his money” pretty much sums it up.  That was me.  It almost felt illegal and I actually hid the results from others fearing that I would jinx everything if I mentioned it. I would often pick up a calculator or paper and pencil calculate out what the sum might be after 5 10 20 years at the current rate of returns.

When a Martingale goes bad

I’m not a market statistician or financial wizard of any sort, so I can’t give a very elegant explanation of what happened. I do know that the financial problems in Europe during the fall of 2011 provided an extremely volatile and choppy market that did not agree with my reversing Martingale EA. It resulted in some whiplash-packed trading weeks and numerous reality checks.

All my gains for the year and then some were wiped out during a few weeks.  The deceptive thing about a Martingale is that 99.9% of time it will look good and make money. When you test it, it is likely you won’t catch it at its worst.  It feeds a sense of denial.  In this case results were good for several months before it lost money.

Once it starts losing, the trades become big very quickly. If you happen to be asleep when this happens, you’re in for a big surprise as you rub the sleep from your eyes and peer at your monitor in the morning.  I know some of you are thinking, “well,  duh”, and to be honest, knowledge of this possibility was always in the back of my head. I thought since the Martingale was a reversing one and would adjust to volatility I was at least somewhat immune to this. I suppose it could have been much worse with a more conventional Martingale.

Another thing to watch out for is meddling.  When things started going bad I slipped into the bad habit of supervising the EA.  I would stop trades just before they were about to recover and the net result was usually to make things worse.

Summary

Since that time, I have scaled back use of the Martingale.  In some type markets I won’t even run it.  I also added a non trading window feature to it.  Specifically I can set it up to shut itself down at specific times of the day.  Now when I go to bed, if there are multiple big financial news reports scheduled for the morning, I set the EA to go inactive before and for sometime after this time to let the associated volatility work itself out.

I sleep better when I know it won’t be running at night.  It’s no longer producing killer returns for me as the volatility will usually make you money, but I don’t have to worry so much about the times when it will create losses, either.  There’s a price to pay for peace of mind. If that means trading less often, I’m all in favor.

Sign up for EA Package


* = required field

powered by MailChimp!