Algorithmic and Mechanical Forex Strategies | OneStepRemoved

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

Trading System Drawdown and Emotion

January 28, 2013 by Shaun Overton 13 Comments

What do baseball and trading system drawdowns have in common? A lot more than I ever realized.

If you haven’t read the book or seen the movie Moneyball (which I highly recommend), professional baseball adopted a statistical approach to recruitment and gameplay around 2000.

The Oakland Athletics adopted the approach before any team. They experienced tremendous success in their first system-driven season, despite countless expert predictions of imminent failure.

I started reading The Signal and the Noise by Nate Silver last night. The baseball chapter picks up where Moneyball left off. Dustin Pedroia, a star second baseman for the Boston Red Sox, enters the scene as an unlikely success story.

Most scouts overlooked him. He is short. He has a paunch and bowed legs. Nobody looks at the guy and thinks “professional athlete”.

Dustin Pedroia held strong through a trading system drawdown of his own

Dustin Pedroia held strong through a trading system drawdown of his own – an unexpectedly low batting average.

Sticking with the system

Pedroia batted a lackluster .198 when the Red Sox brought him to the major leagues in August of 2006. The first month of the 2007 season started off even worse at .172.

 

A team like the Cubs, who until recently were notorious for their haphazard decision-making process, might have cut Pedroia at this point. For many clubs, every action is met by an equal and opposite overreaction. The Red Sox, on the other hand, are disciplined by their more systematic approach. And when the Red Sox looked at Pedroia at that point in the season, James told me, they actually saw a lot to like. Pedroia was making plenty of contact with the baseball – it just hadn’t been falling for hits. The numbers, most likely, would start to trend his way.

“We all have moments of losing confidence in the data,” James told me. “You probably know this, but if you look back at the previous year, when Dustin hit .180 or something, if you go back and look at his swing-and-miss percentage, it was maybe about 8 percent, maybe 9 percent. It was the same during that period in the spring when he was struggling. It was always logically apparent – when you swing as hard as he does, there’s no way in the world that you make that much contact and keep hitting .180.”1

Trading System Drawdown

Every trader goes through a slump – even the best of them. When your trading system drawdown reaches uncomfortable levels, how do you cope?

I had the opportunity to lead managed fund sales at one of the largest forex brokerages in the world. The product was the Sentiment Fund and it was AWESOME. When the fund took off and upper management suddenly got involved, the fund had $40 million under management and nearly 1,000 investors.

If there’s one thing that you can count on with forex traders, it’s that they are going to lose. All the time. No doubt about it.

The firm received real time information on the positions of all clients. Whenever too many traders held positions long or short, the fund did the exact opposite.

That’s it. The automated strategy was stupid simple, but the returns were amazing. The aggressive fund kept the leverage at 2:1, yet was on track to earn 40% annually.

Bad luck

Two months before the hand off, the fund experienced a sharp drawdown of -8%. Like most people, investors thought of 40% returns as 40/12 = 3.3% profit per month. They don’t think about the natural slumps that happen – just like the one Pedroia experienced.

That “surprise” drawdown caused a mass herding effect. It didn’t matter that the fundamentals of the strategy were unchanged. Forex traders didn’t wake up smart last month and know how to game the system. Bad luck happens to the best strategies. Nonetheless, investors ran for the exits from a world class strategy.

Were the guys on the systems desk worried about the strategy that they built? No way! When Pedroia went through his slump, he could have overreacted and start messing with his batting stance. He could have adjusted his distance to the plate or any number of things.

Pedroia knew that his system was good. The systems guys knew their strategy was phenomenal. In spite of all the pressure, they held firm and blew past the drawdown by the time I handed off the sales effort.

What element of trading matches the “swing-and-miss percentage”? The Red Sox clearly used it to justify sticking with their system. In Sentiment Fund’s case, it was knowledge of the underlying system.

How can quantitative traders with less obvious fundamental theories know that their system is sound? I’d love to hear your comments.

1. Excerpted from The Signal and the Noise by Nate Silver, page 104.

Filed Under: Trading strategy ideas Tagged With: drawdown, Dustin Pedroia, forex, system, trading system

Money Management Modeling

April 2, 2012 by Shaun Overton 4 Comments

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 occurring. 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.

Filed Under: Stop losing money, Trading strategy ideas Tagged With: drawdown, money managment, percent accuracy, risk reward ratio, trading, wins

Optimize an Expert Advisor

February 20, 2012 by Shaun Overton 1 Comment

One of the lesser known features of the MetaTrader backtester is the optimization feature. It’s so small that you could be forgiven for overlooking it.

Optimization is the process to maximize a certain outcome. In this case, it’s profit. Any EA developer wants to maximize the amount of profit made over a given period of time. The MetaTrader optimizer allows the trader to search for the combination of inputs that yielded the maximum profit over a given period of time.

The process is identical to running a backtest, except that MT4 runs multiple backtests at the same time. It then organizes the results and offers up the best combination.

Telling the backtester to run in optimization mode is easy. Simply put a check next to the word Optimization. MetaTrader will then sort through the combinations that you tell it to consider.

MetaTrader EA Optimization option

Place a check in the box next to Optimization in the MT4 backtester

The next step is to click on the Expert properties button to the right. A new window appears that contains three tabs: Testing, Inputs and Optimization. These screens allow the trader to inform MetaTrader which variables to consider for testing and how to weight the results.

Testing

The top of the testing section applies to every type of backtest. Here you can select the starting balance. MetaTrader defaults the option to $10,000, although you can make this any amount of your choosing.

The second default option allows the trader to restrict the direction of trades. It’s a frequent expert advisor programming request. It’s also one that is unnecessary. Both the backtester and expert advisor options screen allow the trader the option of restricting trades to long only or short only without additional programming. If the EA is not well programmed, this setting may cause errors 4110 or 4100 to appear all over the trading journal. It’s harmless. The only effect should be that the backtester slows down. It’s the result of writing to the journal hundreds of times or more.

The testing tab of the MetaTrader backtester

The testing tab of the MetaTrader backtester

A groupbox appears underneath these options that inexplicably relates to the optimization process. You’d think it would make more sense to place it in its namesake tab. That’s typical MetaQuotes logic at work.

The first line contains numerous parameters for choosing the best option. User overwhelmingly select for the largest account balance, but other options include the profit factor, expected payoff, maximum drawdown and drawdown percent.

The last line automatically uses a genetic algorithm. Optimization processes use either brute force methods or genetic algorithms. Brute force strikes most people as intuitive although obviously exhausting. The software tests every combination possible. Genetic algorithm’s attempt to make the process more intelligent. When the software sees that certain parameters almost inevitably lead to a losing performance, the algorithm skips similar tests where it expects to lose.

This is a great idea if you have a quality genetic algorithm. My opinion of the MetaTrader backtester is less than stellar. I don’t feel very confident about the algorithm at all. If you don’t mind spending extra time waiting for test results then I suggest unchecking this option. You don’t want to miss a potentially important combination.

Inputs

Most people find this screen confusing. The first column, called value, strictly controls inputs for simple backtests. The Value column is totally ignored during an optimization run.

The inputs tab of the MT4 backtester expert settings

The inputs tab of the MT4 backtester expert settings

The important columns for this task are Start, Step and Stop. Start is the lowest number that the MT4 backtester will consider. Step refers to the interval between the lowest value and the highest value. Tightly controlling this setting allows the user to gain quick insights into how changing the variable values affects performance without dragging the tests out for a full week. Stop is the highest number that the expert advisor will use.

The most obvious candidate for testing in this example is the Take Profit value. The default setting is listed at 50. If you trade the majors, you might want to consider settings ranging between 10 pips and 200 pips. That means that you set Take Profit row to 10 for the Start column and 200 for the Stop column. The real trick here is selecting the Step. If you choose Step = 1, then MetaTrader will run a separate test for every value between 10 and 200. That’s 190 tests, which is overkill. A step of 10 cuts the total number of tests down to 19.

Optimization

This section is the nit-picky part. If a trader feels it’s unacceptable to have 10 consecutive losses in a row, he can place a check next the the Consecutive wins box. MT4 automatically discards any tests which yield a result that contains anything checked off.

The optimization tab in the MT4 backtester expert properties

The optimization tab in the MT4 backtester allows users to discard tests with undesirable traits.

When you finish going through each of the tabs, push OK in the bottom right corner. It’s time to launch the tests.

Curve fitting in the MT4 Optimizer

A word of warning: my personal opinion is that optimizing an expert advisor is usually a very bad idea. The unique settings that yield the most profit in 2012 are unlikely to yield the most profit in 2013. If you don’t control for random chance, there’s a good probability that the 2012 best combination may result in catastrophic losses in 2013.

I recommend that traders pursue any strategy development work in NinjaTrader. I don’t like the idea of optimizing at all. Instead, I always focus on testing strategies for entry and exit efficiency. I know from years of experience that these values never fundamentally change on instruments of the charts traded. Entry and exit efficiencies make wonderful metrics for automated trading because they are so stable.

Filed Under: MetaTrader Tips, Test your concepts historically, Trading strategy ideas Tagged With: backtest, backtester, brute force, curve fitting, drawdown, EA, expert advisor, genetic algorithm, inputs, MetaQuotes, metatrader, mt4, optimization, optimizer, profit factor, Take Profit, testing

  • « Previous Page
  • 1
  • 2
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 © 2023 OneStepRemoved.com, Inc. All Rights Reserved.