Monday, April 12, 2010

Metatrader - Beware of Bar[zero]

Welcome back Meta-Traders.

When programming EA's, beware of doing anything based on Bar[zero].

Its a tempting trap to fall into because many on-screen indicators use Close[zero]. In retrospect, those signals look great because they sometimes seem to catch bar highs and bars lows that were amazingly accurate. The only value that is safe to use is Open[Zero] which is pretty unlikely to change once it prints.

But in reality, those indicators were painted using hindsight and the value of the indicator can't be trusted until the current bar is fully formed and is now one bar old. The net result is you are chasing indicators and taking signals before bar is fully formed. Refresh the chart a few hours later and you will find that the signals you were acting on have disappeared based on the new, updated close of the bar!

An even more extreme case of the pitfalls of acting on bar zero are shown in the graph above. The EA takes an entry signal based on intra-bar data. Then the EA takes an exit signal based on intra-bar data. Repeat this several times and the EA has now chewed up 10% of the equity in your account with a bunch of silly non-sensical trades. Good thing this is a demo account.

Also, beware of any EA that takes multiple entry signals within a current bar. I know of one very expensive commercial EA that does just that. Sometimes all the trades work out and this EA picks up 5 quick profitable trades in a row and looks brilliant. Other times, the market goes the other way and you follow it right off the cliff.

One more pitfall avoided in the road to profitable trading.

Talk to y'all later.

1 comment:

  1. Lesson learned, Chris, there are SO many indicators that repaint that it becomes natural to be suspicious of any system that claims to have great backtests. Since backtests use data that has been 'set' (ie. the hard right edge doesn't count for anything in backtests, but is everything in live trading), it is not at all difficult to create a backtested profitable EA that fails badly in live conditions because of the changing nature of the current bar (the 'hard right edge'). Any system that depends on the value of the current bar can be dismissed out of hand, IMO.

    The commercial EA 'Ultrabot' appears to be of this ilk. The backtests, going back to 1999 were simply fantastic, and so I bought the product. My backtests confirmed the published tests. But the long forward demo (not even live) tests failed utterly, and I suspect the 'bot assumed the current bar would finish at the opening position, as you describe. Since the EA was in an ex4 format, I couldn't confirm this, but what else could it be?? If it was a scalper perhaps the demo performance vs backtesting could be due to interpolation errors, but Ultrabot is not a scalper.

    All was not lost, however, as I was able to get my money back from Clickbank.

    ReplyDelete