From the September 01, 2012 issue of Futures Magazine • Subscribe!

Guide to trading system development

Forming the model

This tutorial covers the processes of automated trading system development and not any specific trading strategy. Because of that, our model logic will be based on a random-entry system to keep the focus on the development process. To gather sufficient data for analysis, the system will day-trade the EUR/USD currency pair, which is both extremely liquid and familiar to most traders.

To create a random entry, the system will simulate a coin flip. Our market model is simply “buy on heads, sell on tails.” Based on the results of the coin flip, the system will buy (enter long) or sell (enter short) at 8 a.m. (Eastern) at the start of the New York trading session. The system will exit the trade at 5 p.m. (Eastern) at the end of the New York trading session. We will test the system on hourly bars (referred to as “H1” in MT4 parlance).

We coded the random logic using MT4’s programming language MQL4. This is done by creating what is termed an Expert Advisor (EA). We called this particular one Random Entry DTS (for day trading system). Our EA used the function MathRand() to generate pseudo-random numbers and a short algorithm was created to simulate a coin flip. At 8 a.m., Monday through Friday, the system “flips” the virtual coin. If the result is a positive number (virtual heads), then the system will initiate a long trade in the euro currency pair. If the result is zero or a negative number (virtual tails), then the system will initiate a short trade.

A fair coin theoretically will produce a 50/50 head/tails split as the number of flips approaches infinity. With a finite number of flips, however, the split will drift from the theoretical, but a sufficiently large number of flips will produce splits that are near to that. With a sufficiently large number of trades, therefore, the split between winners and losers also should approach a 50/50 split.

Comments
comments powered by Disqus