Why Automated Trading?

Why Automated Trading?

No Emotions

Very few traders can successfully control hope, greed, anxiety, fear, and panic in their trading, letting those emotions leak into their trading decisions. Automated trading systems don’t have an opinion and don’t have emotions – they stick to a programmed set of rules no matter what is happening around them, providing the discipline and patience required for a more objective and reliable approach to trading.

Backtested

While it is largely impossible to test how your gut feelings and intuitions about a market would have performed in the past, automated trading systems can easily be backtested using historical prices to see how the system would have performed (hypothetically) if it had been active in past market environments.

Forward-tested

Given the limitations of backtesting, we also forward-test each trading strategy – running the strategy in real-time on live market data. This out of sample test can help confirm the effectiveness of the trading strategy on today’s market climate and expose any problems inherent in the code.

Real Money Fills

Knowing how actual investors are doing on a trading strategy with real money is the most valuable piece of data. Isystems tracks the buy and sell prices (‘fills’) for each and every user for each trading strategy, showing subscribers the best fill price received, worst received, and average price.

Fully Automated

Automated means it runs automatically, without the need for you to be glued to the computer. The trading strategies react to price movements and place orders to enter and exit as needed. Once activated, it runs day in and day out, doing the hard work for you.

Diversified

Trading strategies come in many shapes and sizes, some preferring to pick market tops and bottoms, others riding the daily trend. They run on over 40 markets spanning different countries and asset classes. Diversifying your portfolio of strategies can help reduce risk and lower drawdowns.

Explore Systems Link

Explore our trading systems and elevate your strategy today!

Explore Systems

Developing the first strategy

Simple Moving Average (SMA) and Golden Cross Strategy

Simple Moving Average (SMA) Formula

The formula to calculate the Simple Moving Average (SMA) is as follows:

SMA = (Σi=1N Pi) / N

Where:

  • Pi: The price (usually the closing price) at period i.
  • N: The total number of periods used to calculate the average.

Example:

If we calculate a 5-day SMA for a financial asset with the closing prices:

100, 102, 104, 106, 108

The SMA would be:

(100 + 102 + 104 + 106 + 108) / 5 = 520 / 5 = 104

So, the 5-day SMA in this case is 104.

This value is updated as new prices are added and older ones are removed, creating a smoothed line that helps identify trends.

Application to Automated Trading

Applying a moving average crossover in a trading strategy involves using two moving averages, one fast and one slow, to identify buy or sell signals based on market trends. Below is a professional approach to implement it:

Defining the Moving Averages

  • Slow Moving Average: Calculated over a short period (e.g., 20 periods), reacts more slowly to price changes.
  • Fast Moving Average: Calculated over a longer period (e.g., 50 periods), shows a more stable trend.

Crossover Criteria

  • Bullish Crossover (Golden Cross): The fast moving average crosses above the slow moving average. Buy signal.
  • Bearish Crossover (Death Cross): The fast moving average crosses below the slow moving average. Sell signal.

Sample Code to Implement a Golden Cross

using System.Collections.Generic;
using TradingMotion.SDKv2.Markets.Charts;
using TradingMotion.SDKv2.Markets.Orders;
using TradingMotion.SDKv2.Markets.Indicators.OverlapStudies;
using TradingMotion.SDKv2.Algorithms;
using TradingMotion.SDKv2.Algorithms.InputParameters;

namespace GoldenCrossStrategy
{
    public class GoldenCrossStrategy : Strategy
    {
        public GoldenCrossStrategy(Chart mainChart, List secondaryCharts)
            : base(mainChart, secondaryCharts)
        {
        }

        public override string Name
        {
            get { return "Golden Cross Strategy"; }
        }

        public override bool ForceCloseIntradayPosition
        {
            get { return false; }
        }

        public override uint MaxOpenPosition
        {
            get { return 1; }
        }

        public override bool UsesAdvancedOrderManagement
        {
            get { return false; }
        }

        public override InputParameterList SetInputParameters()
        {
            return new InputParameterList
            {
                new InputParameter("Slow Moving Average Period", 20),
                new InputParameter("Fast Moving Average Period", 5),
                new InputParameter("Pips Take-Profit", 120),
                new InputParameter("Pips Stop-Loss", 60)
            };
        }

        public override void OnInitialize()
        {
            var indSlowSMA = new SMAIndicator(Bars.Close, (int)GetInputParameter("Slow Moving Average Period"));
            var indFastSMA = new SMAIndicator(Bars.Close, (int)GetInputParameter("Fast Moving Average Period"));

            AddIndicator("Slow SMA", indSlowSMA);
            AddIndicator("Fast SMA", indFastSMA);
        }

        public override void OnNewBar()
        {
            var indFastSma = (SMAIndicator)GetIndicator("Fast SMA");
            var indSlowSma = (SMAIndicator)GetIndicator("Slow SMA");

            if (GetOpenPosition() == 0)
            {
                if (indFastSma.GetAvSimple()[0] > indSlowSma.GetAvSimple()[0] && 
                    indFastSma.GetAvSimple()[1] < indSlowSma.GetAvSimple()[1])
                {
                    Buy(OrderType.Market, 1, 0, "Golden Cross - Open Long Position");
                }
            }

            PlaceExitOrders();
        }

        protected void PlaceExitOrders()
        {
            if (GetOpenPosition() > 0)
            {
                var ticksTakeProfit = (int)GetInputParameter("Pips Take-Profit");
                var ticksStopLoss = (int)GetInputParameter("Pips Stop-Loss");

                var takeProfitLevel = GetFilledOrders()[0].FillPrice + (ticksTakeProfit * Symbol.TickSize);
                var stopLossLevel = GetFilledOrders()[0].FillPrice - (ticksStopLoss * Symbol.TickSize);

                ExitLong(OrderType.Limit, Symbol.RoundToNearestTick(takeProfitLevel), "Take Profit");
                ExitLong(OrderType.Stop, Symbol.RoundToNearestTick(stopLossLevel), "Stop Loss");
            }
        }
    }
}
    

Example of the Golden Cross Strategy

*To achieve these results, it is necessary to perform optimizations and tests across different timeframes to evaluate performance, as well as to incorporate additional filters and logic to refine the strategy further.

Developing the second strategy

Subscribe to Our Newsletter

Stay updated with the latest news and updates. Subscribe to our newsletter today!

Scroll to Top