Feb 10, 2012

Dan-D1-RSI+EMA-robot EA

This robot from 13th May, 2010, stands out in my mind as one of my favorites. I remember it working really well for a few weeks, and I think I even ran it live at one point.

Unfortunately, I must have started it during a particularly strong trend, because as soon as the trend ended, it started failing and failing badly, and I discontinued testing.

It has "D1" in it's title because I had decided the daily time frame was great. Great enough to warrant adding "D1" to the title, anyway.

Default stop-loss is 200, take-profit 800, trailing-stop 100. Lot size 0.1. Reasonable settings for a robot running on the daily time-frame.

By this point my robots were getting more complicated, and I started including more code cannibalized from other robots to check various conditions.

This robot works by checking several indicators - 4 periods of RSI (5, 10, 15, 20), 3 moving averages (5, 25, 75 EMA), and the force indicator (another of my favorites).

If all periods of the three indicators showed bullish momentum, the robot would open a BUY trade. But not before first checking:


  • If the market was over-brought or over-sold (by calculating RSI(2) for various time frames)
  • Making sure the ASK/BID price wasn't too far away from a 3 period EMA
  • Making sure the price hasn't exceeded it's 20 period Bollinger Band. 
  • The spread was not too high


Pretty clever, huh?!

This robot would close a trade if any of the indicators no longer showed momentum where it should be, and if the order was in profit.

There was also code to check a 3rd party news indicator, but apparently it never really worked well. I removed it for this test.

As stated above, this robot ran well for a while, then bombed.

A quick back-test with the settings mentioned from 1-1-2011 to 1-1-2012 show:



Amazing! A $726 profit, if you were prepared to wait an entire year. It wins 65% of all trades, with draw-down at 11.20%. In theory, with a lot size of 1, you'd earn $7260 after a year, or a 72% return on a $10,000 investment. (note: please do not do this. "EDHD" (Extremely Dodgy History Data) almost ensures that these results are completely wrong).

The equity curve doesn't look too happy, though. It reached peak profit after 18 trades, suffers a decline, then slowly regains most of it's losses.

This is not a good. What you want is a nice consistent upwards slope to your equity curve.

Still, again not horrible results for an early robot design (in that it didn't completely bomb. The equity curve still shows that this is not a robot you'd ever want to run).

I could probably even improve this robot further, by including better triggers. If the conditions were met for a BUY trade, for example, I could make it look for a decent entry on a lower time frame, such as using 5 min Bollinger Bands (if the price exceeds the lower BB on 5 minute time frame, BUY if the other indicators show bullish momentum) or fractals on the 15 or 60 minute time frame.