Friday, September 25, 2009

MetaTrader 5 Beta review

The MetaTrader 5 blog has translated a review of the closed beta. It was originally written in russian here. Hopefully the public beta is just around the corner, with one comment on the oroginal russian site suggesting 1st October.

"Practically, everything that many developers wanted from MQL 5 and Metatrader 5 was implemented and realized at the highest level. The major change in MQL5 is the introduction of OOP (Object-oriented programming). Professional programmers have now more opportunities, but those who learned to write in MQL4, can use the MQL4 programming in MQL5 without the benefit of OOP."

Thursday, September 24, 2009

Assessing risk

Assessing risk - the most important aspect of any financial investment, and critical for evaluating Forex trading systems.

I've often seen comments in Forex forums something like this: "I'm not looking for a gold mine -- just a system that makes 10 pips per day". So let's take this 'modest' requirement to its conclusion with some back-of-the-envelope calculations. Come on, admit it, you've done something similar -- I have. In order to buy 1 lot of EURUSD at 200:1 leverage I have to supply $100,000/200 = $500 of margin from my account. 10 pips = $100 profit @ 1 lot. Hey, wait a minute! [scribble, scribble], that means that I can make $100 * 5 days a week * 50 weeks = $25,000 per year or 5,000%, all from a $500 investment!!!! And if I increase the investment over time to 10 lots, I could … I can …….... eyes glaze over, images of palm trees on a tropical beach drift into view.

Past performance is not necessarily indicative of future results
The hard cold reality, of course, is risk, manifested as drawdown. Focusing only on the profitability of a system ignores this critical financial and psychological element, like agreeing to a major medical procedure without knowing how often it has been successful.

Historical, backtested risk is not difficult to calculate. Conversely, obtaining a useful estimate of future risk is (or should be) the single most challenging and elusive task that faces a trading system developer. Here are some ways in which I attempt to assess future risk
  • The simplest assessment of risk is a reward:risk ratio calculated from (total profit)/(maximum drawdown). The MetaTrader 4 Strategy Tester reports individually on these, and it's a real pity that it cannot optimise on the combination.
  • When people visually assess the smoothness of a backtesting equity curve, they are in effect trying to assess future risk. Calculating the smoothness of equity curves is again absent from the MetaTrader 4 Strategy Tester. That's why I wrote an Extended Strategy Reporter, which among other parameters calculates the Sharpe Ratio and modified Sharpe Ratio, both of which provide a numerical indication of smoothness.
  • Once an optimised set of parameters has been found, it is important to verify that these are part of a "rounded hill" of generally low risk values. A set of parameters that has no neighbors is almost certain to be curve-fitted.

Friday, September 18, 2009

Breakout Neuro EA drawdown and work in progress

Hmmm - the Breakout Neuro EA is in a big drawdown at the moment. Taking the point that I first started forward testing on 7th August to now, it had a peak equity of about +1,600 pips with a drawdown of -300 pips, but then the drawdown started in earnest and is now -900 pips. That's partly bad news, but I'm hoping that this is normal behaviour - it is after all a fixed optimisation from only three months of data which is potentially starting to lose its relevance.

The work I am doing now is
  • Was the initial gain a fluke? I think it's time to manually re-optimise the fixed neural network to see if it can again show a period of profitability
  • Take the concept further to a self-optimising neural network that frequently goes through a learning cycle, say every day or perhaps driven by "failure", ie a series of losing trades
  • Since the optimisation relies heavily on the fitness measurement from the validation equity curve, I'm expecting to have to spend time on getting that right. Is the profit/drawdown ratio good enough, or will it benefit from a more sophisticated form of equity curve measurement such as Sharpe ratio (profit/standard deviation)?
  • The EA engine I used could also do with some tweaking, because it currently issues long and short trades blindly. Instead I will change it so that new long positions will first exit any existing short positions, and vice versa.

Thursday, September 17, 2009

MetaTrader 5 is in closed beta testing

At last MetaTrader 5 has been released in closed beta testing on 9th September, see here. I don't have a copy unfortunately, but am looking forward to the public beta, which I am guessing will start sometime in October. They cancelled the 2009 trading championships so they could concentrate on MT5 development, and I think many traders like me will be setting themselves a goal of entering the 2010 championships. If I ever get something going with my neural network approach then I'll find it much easier to translate the C++ DLL that I am writing into MT5.

My guess is that the earliest that brokers will start changing over to offering live MT5 trading is late in 2010.

Monday, September 14, 2009

Forex signals services

There are a number of automatic signals services out there which present a smorgasboard of systems to chose from. For a while I was using FXDD Auto until I drove an account into the ground. This is no reflection on them, because their platform is quite good, but on my poor selection of systems, and I must take the time to check out their latest offerings.

FXDD Auto has a very elegant method of charging for their services - they simply add an extra pip onto every trade. This means that you can create a balanced portfolio of systems which can be easily adjusted at any time. You can start at 0.1 lot trades and, if you're lucky enough to watch your equity increase, there is automatic money management available to gradually increase trade (and fee) size. But, vouching from experience, you can also create an absolutely amazing equity curve from historical system results, only to watch it grow … then crash. You have to really question whether the builders of some of the systems have any genuine belief that they are profitable in the long term.

Another signals service that I am actively using right now is Global Forex Signals, with the PipsRain system. This system reassuringly doesn't boast massive pips per week, or a ridiculously high profitable trade ratio, but even so I am only trading it at 0.1 lot at the moment. The system costs $150 per month, so I'm hardly grossing any profit right now. Here's a forward test at 1 lot per trade (ahh, the peaceful luxury of demo accounts). The link updates only once a day to make it pointless to copy, so I hope I'm not violating any agreements. Come to think of it, they should be pleased that I'm promoting them.

GF Signals provides a free EA which reads their signal emails to automatically drive MT4. I've never tried it because I wrote a similar EA coupled with a gmail reader dll a long time ago before they released their own version. It worked fine, but I was quickly frustrated by the slippage from slow delivery of emails - it's quite normal to see at least 5 pips of entry and exit slippage simply because of the time delay. So I wrote a web page scraper instead which polls their signals web page and is far more reliable. The email reader approach would be fine as long as the average profit per trade is reasonably high.

So here's my approach to selecting a signals system:-
  • At least 6 months of history, preferably 12 months
  • Good profit/drawdown ratio
  • Trading only 0.1 or 0.2 lots. This allows money management to be implemented earlier
  • Maximum profitable trade ratio about 80% to avoid the luck factor
  • Active use of stops in the 50 to 200 pip range
  • Absolute minimum average profit per trade of 20 pips
  • Use very low leverage
 I should emphasise that I am just a paying customer of FXDD Auto and Global Forex Signals, nothing more.

Monday, September 7, 2009

Volatility settles down

I've been looking at a few daily charts of volatility, as measured by a 14 period Average True Range.  Here's EURUSD as an example.



Interesting to see how much the volatility exploded with the GFC.  It hasn't quite settled down yet, but at least the trend is down, and it could meet the long term gradual rise quite soon.  It makes me realise how much the forex market behaviour has changed over the last year.  Will a system backtested as profitable through that timeframe still work well in the future?  Is it possible and desirable to adjust for volatility, eg by using ATR based stops instead of simple point multiples?

Note to self:
  • Treat August 2008 to February 2009 as an atypical timeframe, and expect unusal system behaviour during that time.
  • Try optimising from, say, January 2004 to July 2008, and compare with August 2008 to February 2009, and March 2009 to present.

Friday, September 4, 2009

Success so far with the Neural Network EA

A very pleasing result so far for my forward test of the Breakout Neuro EA V1_0.  I first wrote about the Neural Network approach I'm using in August


A recap on how this EA works:
The base EA is a simple 4 bar breakout on a 15 minute chart with 100 pip stoploss and takeprofit. Not surprisingly this is miles from being profitable in its own right. A 19-10-1 neural network provides an entry filter which is very effective (at the moment) at entering swing trades in the long direction.

The NN was optimised using an early stopping approach: backpropogate against a factset from 6 to 3 months ago, and select the NN configuration which delivers the best profit/drawdown on data in the last 3 months.

So how come I haven't broken out the champagne? The EA is making money isn't it? The problem is that the approach of optimisation and run until failure, or regular optimisation, is not backtestable. So, I thought, why not incorporate regular optimisation into the EA itself?

So I started to laboriously code the NN backpropagation algorithm into MT4 ... and gave up. It's not impossible, but translating what was a neat bit of OOP into a C-style environment, with no debugging facility, was painful. I also realised how many loops and arrays are involved and became concerned that MT4 would run too slowly.

So, for now, the opposite approach. I'm in the middle of writing a C++ dll which will spoon-feed everything to the EA, including the entries. All the EA will need to do is send out the latest closed bar info every 15 minutes and ask if there is an entry. Stay tuned for the results - in a week or two.