Algorithmic and Mechanical Forex Strategies | OneStepRemoved

  • Articles
  • Sophisticated Web Sites
  • Automated Trading
  • Testimonials
  • Contact

Creating A Trending Or Ranging Expert Advisor… Not Both

April 11, 2013 by Edward Lomax 5 Comments

On a previous blog post, Shaun Overton said something that is insightful and simple, but often overlooked by people attempting to program their own trading strategy into a working expert advisor. The concept has been confirmed from years of my own manual trading. And I believe if you are to create a working automated trading strategy… this is the place to start.

This is the portion of the blog post I am referring to:

“Certain rules do work dramatically better during different market conditions. The key is to separate the conditions, then apply the strategy selectively. Most expert advisor designers try to develop a strategy that works all the time.

It doesn’t work that way. When the EA starts to hit a wall on the design, the trader responds with new additions and tweaks to force the performance to improve the general performance.

What I’m working on now is a set of rules to identify various market types. I like to think of it as “don’t compare lawn mowers when it’s raining.” There’s a time and a place for each approach and behavior. The trick isn’t so much the rules, but deciding when to apply them.

Categorizing the market helps make the strategy selection process far easier. If the market is highly volatile and ranging, then select a scaling strategy that works well in ranging markets. If the market is trending quietly, then perhaps a basic trend strategy would work perfectly well.”

The full blog post is here: Expert advisor versus manual trader

Can You Create an Expert Advisor For All Market Conditions?

Did you catch the change in approach to developing an automated robot that can increase your possibility of success?

While most expert advisor creators seek to build an automated trading robot that works well all the time… the real opportunity is developing a system to determine what type of market behavior is present, and then applying the correct trading method for the market.

  • If the market is trending, apply a trending strategy.
  • If the market is ranging, apply a ranging strategy.

Simple right? Maybe so simple it is often overlooked. (I’ll go into reasons I think people make these mistakes with expert advisors in future posts).

Let’s take a look at what I am talking about. Here is a snapshot of a trending market:

AUDJPY Trending

The AUDJPY moved in a strong trend this week

The photo shows the AUDJPY pair on the H1 timeframe for the period of April 3rd to April 10th. Clearly, this is a trending market. Let’s say we applied a simple strategy of BUYING the end of day candle close and closing the trade the next day. (This is just an example, so I’m not going into stop loss, take profits or anything else you would need to do with a real strategy. I just want to keep it simple).

This simple strategy would have resulted in 769 positive pips.

OK, let’s look at an example of a ranging market:

Range trade the EURUSD

The EURUSD has been ranging this week

This is a snapshot of the EURUSD pair on the H1 timeframe from March 27th to April 3rd. This time, we are going to SELL at the end of day candle close when price is near the top of the range, and BUY at the end of day candle close when price is near the bottom of the range. (Again, this is very simplistic on purpose and only for sake of example).

The result of this simple strategy would have been 286 positive pips.

So, potentially 1053 pips of profit in less than two weeks of trading, on two currency pairs, taking only one trade a day on each currency pair. Pretty impressive, isn’t it?

Clarification

I’m not suggesting I would be able to correctly identify the beginning and ending of the range or the beginning and ending of the trend. I don’t have a crystal ball.

What I am suggesting is once the type of market is identified, it is very simple to get nice profits from even the simplest of trading strategies.

Focus On The Right Strategy For The Right Market Condition

When people hear words like “automated” or “robot”, they think the possibilities are endless. Visions of extreme profits very quickly immediately flash into their heads. They believe, and are lead to believe by unscrupulous, commercial robots marketers, that an automated trading solution should greatly outperform their manual trading counterparts.

If a good manual trader can get 40% profits a year… a robot should be able to get 4000%.

As a result, they set out to build robots that trade well in every market condition. Plus, the robot should trade multiple times during the day, pulling out more and more profits each time. If that were possible, incredible wealth is just around the corner.

The truth…

Trying to come up with an extremely complicated set of trading rules to profit in every market is a very difficult task to undertake. Usually what happens is the strategy works very well in certain markets… but gives back a lot (or all), of the profits when the markets change. When tweaks are made to keep this from happening, the robot stops being as profitable when market conditions return to favorable.

My advice is to simplify the goals you want to achieve with your automated trading.

  • If you have a good strategy that works well in trending markets… create a robot to trade only in trending markets and work to develop rules to determine trending markets and their direction.
  • If you have a good strategy the works well in ranging markets… create a robot to trade only in ranging markets and work to develop rules to determine the beginning and end of the range.

A automated trading robot does not have to trade all the time to be extremely profitable. It only has to trade well in the market it is created for. When thinking of automated trading, a specialist is much more desirable than a jack-of-all-trades.

I truly believe switching focus from a wonder robot that trades all the time to a specialized robot that trades only under the best conditions is the path to long term success with automated trading. I hope this post has give you some things to think about and has sparked ideas that leads to your future success.

Next Friday I want to talk about Why Forex Robot Creators Don’t Use Sensible Strategies. See you then.

Filed Under: Trading strategy ideas Tagged With: AUDJPY, eurusd, expert advisor, ranging, trending

Range Trade at High Frequency

February 28, 2012 by Shaun Overton Leave a Comment

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.

Filed Under: How does the forex market work?, NinjaTrader Tips, Trading strategy ideas Tagged With: API, commission, expert advisor, FIX Protocol, high frequency, limit orders, market making, metatrader, ninjatrader, order flow, profit factor, range trading, ranging, spread

Donchian Channel

January 16, 2012 by Shaun Overton Leave a Comment

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.

Filed Under: How does the forex market work?, Trading strategy ideas Tagged With: breakout, contrarian, donchian channel, forex, futures, ranging, Turtle trading

FREE trading strategies by email

Trending

Sorry. No data so far.

Archives

  • Dominari
  • How does the forex market work?
  • Indicators
  • MetaTrader Tips
  • MQL (for nerds)
  • NinjaTrader Tips
  • Pilum
  • QB Pro
  • Stop losing money
  • Test your concepts historically
  • Trading strategy ideas
  • Uncategorized
  • What's happening in the current markets?

Translation


Free Trading Strategies

Privacy PolicyRisk Disclosure

Copyright © 2022 OneStepRemoved.com, Inc. All Rights Reserved.