Davor's Trader by Mihailo Despotovic, December 2013

A contract job from the time of my startup, MiRteh, for Davor Urošević, a FOREX trader. His idea was a breakout: watch EUR/USD from 11:00 to 13:30 and note its high and its low, then, from 13:31 to 17:00, buy if the price breaks out above the high, sell if it breaks down below the low, and get out when it turns. It started, in November, as a Java program to sit between his data and MetaTrader, and ended, in December, as an Expert Advisor for MetaTrader 4 itself, written in MQL4, which I kept pasted under the Java code.

The plan

Input file(data, parameters) The program I'm writing Output file(commands for MetaTrader) MetaTrader YOUR PARTMY PARTYOUR PART

Redrawn from my diagram of November 17, 2013, which was in Serbian: “TVOJ DEO”, your part, and “MOJ DEO”, mine.

The Java program

Davor's Trader 1.0, as Trader.java builds it: data on the white side, the program on the blue side, and a log below. It reads a data file, and it clears, but its Process Data is still a // todo: it only checks that there is something to process. The button below puts the Expert Advisor in the program pane, where it would have gone.

Davor's Trader 1.0 ©MiRteh 2013 mihailod@me.com

The Expert Advisor, in a MetaTrader 4 tester

The MQL4, ported line by line and run in a small MetaTrader 4 strategy tester, tick by tick, as MT4's tester runs it. The market is made up: EUR/USD ticks every few seconds, calmer at night, and on some afternoons with a trend, from Monday, December 2, 2013. Or load real history exported from MetaTrader: 1-minute bars as date,time,open,high,low,close,volume. The made-up market says nothing of how the strategy would do on a real one.

OrderOpenedTypeLotsPriceClosedPricePipsProfit

The bugs, and the fixes

There is no MetaTrader here to check the port against, so it was checked with eight made-up days that test its rules, each run as written and fixed; breaking the port on purpose in eight ways, each was caught. As written, the EA traded once or twice in the first days of a test and then stopped for good: in 12 made-up markets of two weeks, it traded on 1 to 4 days, fixed on 6 to 10.

The original Java code: Trader.java

    
The Expert Advisor, in MQL4, as it was pasted under the Java code