Begginner’s guide to trade automation ($spy $spx $eurusd)

It is the process of testing a specific trading strategy or idea, and see how it behaved in the past, or, simulate it with past data. All this with the aim of measuring the effectiveness of that strategy/idea.

For example, suppose you want to test a strategy based on the idea that the EUR crosses below the bollinger band. Usually, this type of strategy says that when we break below the bollinger band, it is time enter a long trade (see, and exit the trade when EUR touches the upper band.

Therefore, your setup has well defined enter and exit conditions, and you can probe how it behaved in the past: that is the backtesting.

The backtesting will give you statistical data, that let you know how good that setup is or not. For example, can get the following (among others):

  • Number of trades in the testing period.
  • How many were for profit, and how much for loss.
  • What was the ROI of this setup.
  • How much risk your system has taken.

Something very important when we do backtesting, is that “Past performance is not necessarily a guarantee of future returns!!”. The goal is just to know how well or bad your system behaved in the past.

Platforms to Backtest

There are plenty of platforms to perform backtesting, from the very basic, which do not require any programming knowledge, to the most advanced platforms. Therefore, I have decided that for this article use NinjaTrader platform (, it is free, and basic but at the same time it allows you to build complex strategies, and once you have your system ready (enter/exit conditions), you can connect it with any broker for live trading. The only thing challenging is that you will have to learn some programming (C#).

In this series of articles, we will not be focus on how to use this platform, but to discuss the results of different trading systems.


First backtesting: crossing system SMA 50 / SMA 200 on EURUSD (in 60 minutes)

This is one of the most used systems by traders around the world, much has been written about it, and very few know the true behavior of this system and what’s the best way to use it.

This system is also known as “Golden cross” and many traders use it as a signal of trend reversal.

It is based on two moving averages where one of them crosses over the other. The Golden cross occurs when the SMA-50 crosses above the SMA-200, giving a long signal. On the contrary, when the SMA-50 crosses below the SMA-200, it is considered a short signal.

Once defined the entry condition, we define for how long we will stay in the trade and when to trigger the exit signal. When we are in a long trade (SMA50 crossing above SMA200), we expect the inverse to get out (SMA50 crossing below SMA200). Same for short trades, that’s we exit when SMA50 crosses above SMA200.

So, now that we have the entry and exit conditions very well defined, let us proceed to test such system on EURUSD over a period of one year.


Below I describe the steps required to create this system in NinjaTrader:

  1. Create the strategy and define when to ENTER a trade (long and short)

Codigo Ninjatrader para definir entradas

2. Write the code to EXIT the trade:


3. Once this system is executed we obtain the below results.



From the result, we can say that, in that period, we have had a total of 46 executions, where 24 were for losses and 22 for profit. So we can say that our system has a 52% effectiveness.

This system is giving us a net return of $255, or in terms of percentage, 1.86% return.

Personally, this seems to be a bad system if we compare the 1.86% return compared with S&P 500’s return.

In the next article, we will examine possible improvements we can add to this system, trying to improve the overall return.

Ariel Silahian

One thought on “Begginner’s guide to trade automation ($spy $spx $eurusd)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.