“R” scripts for Metatrader ….. The first steps of many for proper trading

I have designed and developed Automated Trading Systems (ATS) for few years now. Since trading live, I have been fairly profitable (that is, I achieved my goals). However, I had the unsatisfactory feeling that I was missing some information to increase the level of trust in my systems … I was missing the proper tools to closely examine, and follow-up on the Real Equity Curve of an ATS.

I define the Real Equity Curve (REC) as the accrual of the

In-Sample backtesting Period + Out-Sample backtesting Period + Paper Traded Period + Live Trading Period.

There are quite a bit of information on the web for such but I did not find any Free Open Source tools to perform such assessment, specifically for Metatrader. Indeed, I do use MT4 for trading my strategies, and it’s fine with me; no issue nor any concerns. You might think otherwise but I will not go there … that’s far, far from my current objective.

Moving from one thread to another, I found this particular one: Synthetic hedges, cointegration, mean reversion and similar stuff (related to: MQL4->R-project – Interface Library).     Well, this was more than I needed to finally get a kick-start attempting to fill my needs for REC analysis.

I have started a GoogleCode SVN which contains my R scripts along with example files. My objectives are to design and implement the following:

  • Analysis of multiple MT4 StrategyTester [.htm] files … as I realized most, if not all, the software out-there are commercial solutions
  • Analysis and Follow-up of ATS through Real Equity Curve evaluation
  • Provide a detection for ATS performance Break-Down … to determine as soon as possible when things get ugly

In a second session, and because I stumble across few interesting information here and there, I will be looking at the following:

  • Strategy Optimization of MT4 ATS through R
  • Enhanced the analysis of ATS performance, through System Consistency evaluation for example
  • Enhanced the REC evaluation with Monte-Carlo analysis and Bayesian Statistics
  • and eventually combine the above to investigate Computer Generated ATS (CGATS).

As a first start, thereafter I present 2 examples of my programming kick-start: (1) The aggregation of multiple StrategyTester reports and, (2) the visual follow-up of an optimized MT4 Moving Average from backtesting to paper-trading. Every information and material needed can be found at http://code.google.com/p/rscripts4metatrader/

(1) Using: MT4_StratRep_Analyzer()

(2) Using: MT4_RealEquityCurve_Analysis ()

Metatrader Optimization on the Moving Average EA for the period 2008.01 -> 2009.01

3    2408.02    694    1.27    3.47    784.52    18.86%    MovingPeriod=60    Lots=0.1     MaximumRisk=0.02     DecreaseFactor=3     MovingShift=6