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.
Redrawn from my diagram of November 17, 2013, which was in Serbian: “TVOJ DEO”, your part, and “MOJ DEO”, mine.
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.
The application is closed.
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.
| Order | Opened | Type | Lots | Price | Closed | Price | Pips | Profit |
|---|
Bid - lo < pipsEntry: the price anywhere below 4 pips above the low, so a sell could open as soon as
trading began, with the price sitting just above the low. Fixed, it waits for the price to fall 4 pips below it.negativeStopSell, 30 pips; the sell's used
positiveStopSell, 4.pipsProfit isn't used; and a market order gets an expiration time, which is meant for pending orders.
In the Java program, Process Data looks at the blue program area while its message speaks of the white one.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.