Automated Trading System – The Essential Tutorial for Dummies


Automated Trading System Essential Tutorial for Dummies cover

In this tutorial, you will learn all the fundamental concepts of an Automatic Trading System.

You will learn the various phases for the construction and optimization of a trading system and its evaluation.

 

Generally, the emotional component influence the trader who operates in a discretionary way. Often the sentiment leads him to make wrong decisions.

It is essential to use a trading plan to avoid these mistakes. This plan imposes strict discipline in various trading choices.

It is necessary to establish:

What are the markets and instruments on which you intend to operate?

 

Time Frame

The time frame on which you intend to operate.

The trader, depending on the time available, must choose whether to build intraday trading strategies or overnight strategy.

 

Identify market entry timing

To obtain strong entry signals, the trader must determine all criteria before opening a new position.

To go long, for example, it can be imposed that the following directional trend indicators are in a long position. The trader can impose that the RSI oscillator is signaling an oversold area.

 

The initial stop-loss

The initial stop-loss is the maximum loss that the trader is willing to accept when opening a new position.

Its determination depends, in particular, on the level of risk that the investor is willing to assume.

 

The trader should only focus on those situations that, from a risk/return point of view, appear most favorable.

 

You can express your initial stop-losses as a fixed percentage, in monetary terms, and at fixed points.

You can also use a graphical stop-loss.

trading system essential tutorial

The position management

In addition to the initial stop-loss, it is appropriate to define the rules for closing the position that may occur:

  • When reaching the predetermined target from a graphical point of view.
  • When reaching the predetermined target based on the initial risk.

 

The trader can choose to manage the position with a trailing stop.

Some indicators, such as the SuperTrend or Parabolic Sar, can be used for this purpose.

 

All these rules are essential both for the discretionary trader and for automated trading system developer.

A trading system systematically analyzes the market and automatically provide buying or selling signals.

 

There are two main types of Trading systems: Trend Following Systems and Reversal System.

 

Trend following trading systems

These systems have the task of identifying, very often with the use of appropriate quantitative indicators, the primary trend followed by prices and generating signals that converge with the current trend.

In an upward trend, therefore, the system provides only a long signal, while in a downward trend, it sends only short signals.

Using these systems, you often use directional indicators because you will open a new trade only in the direction of the primary trend.

For example, such a system provides for the opening of a long position when the short-term average crosses the slowest average from bottom to top. We can maintain the position as long as prices remain above Parabolic Sar.

 

Breakout systems

Generally, the trend following is also a breakout strategy. These systems must identify essential areas of support and resistance; the breakout causes a rapid acceleration in prices.

 

A typical bullish breakout candle must have a wide range, sharply increasing volumes, a maximum higher than the peak of the last 20 bars.

 

This candle demonstrates a bullish strength and therefore provides long trading signals.

 

Reversal/contrarian systems

During particular situations of excess that may occur on the market, we can predict a reversal move.

 

  • We can try to enter long the market lows to anticipate a possible rebound in prices during an oversold moment.
  • During overbought situations, we can try to enter short near the market highs to anticipate a possible price correction.

These systems very often combine a situation of excess achieved by the market, with some reversal signals provided by prices.

 

 

It is necessary to verify the past results of the system.

For this reason, backtesting must be carried out, the objective of which is to evaluate the system’s goodness.

 

The construction of a trading system consists of two phases:

The optimization phase.

The backtesting phase.

 

The optimization phase

After selecting the operating criteria and related parameters, we begin the optimization phase.

Using a historical database In Sample, we can optimize the parameters of the system.

In the backtesting phase, instead, we use a database Out of Sample. In the optimization phase, we will use Out of sample data because it’s unknown to the trading system.

 

It often happens that a system produces excellent results when applied to the past time series, but then generates losses when used in real trading.

Very often, it is an overfitting problem — for example, an excessive adaptation of the parameters to historical market trends.

 

For this reason, we use a validation mechanism. We divide the historical series into periods In Sample and Out of Sample.

Comparative analysis of the results obtained over different periods makes it possible to measure any deterioration in the performance and robustness.

 

Using trading systems, we can verify the validity of a given trading strategy statistically.

 

This verification takes place with a backtesting procedure, i.e., the simulation of all the operations that historically, the strategy in question would have generated in the past.

 

The System Report automatically records all operations.

The System Report is a series of data. It is particularly useful to carry out a qualitative assessment of past operations.

 

It should be noted that it is not possible to give a “unique” judgment on the quality of a system.

 

The Platform

There are many platform for the automated trading system, you could find and try many of this in internet. To experiment with some trading platforms, you could consider using a virtual machine. I found this useful tutorial for installing the Virtualbox on the bitcu.co specialized site.

 

How to Evaluate a Trading System

 

Several technical parameters are used to assess the quality of back-testing operations:

 

Equity Line

Equity line: represents the cumulative trend of profits and losses generated by the system.

 

It is the line that expresses the trend of a hypothetical capital managed following the signals generated by the system.

The Equity line, therefore, shows how much money the trading system makes in a period.

 

The closer the Equity line gets to a 45° inclined line, the more the system has been able to guarantee constant and linear gains.

The Equity line can be:

  • closed trades equity line if the system updates the line only at the close of each transaction,
  • open trades equity line if the system updates the line even with a transaction still open.

 

In a daily trading system, every day, you will have an update based on the closing price.

If it is a long transaction and has an overnight duration, open equity will rise on the days when the underlying has risen and fall when the underlying has fallen.

 

Profit

The profit is the gain obtained from the operations generated by the system in the period over which it was applied.

Absolute gain is the first parameter of a system’s evaluation, but it can often be misleading, as it must always be associated with other elements.

 

Profit can be:

  • Net: does the trading system realize the actual gain.
  • Percentage: is the return on investment.
  • The estimated annual % is the total gain, divided by the number of years.

 

The average is the total gain divided by the total number of operations.

 

The Maximum Run Up and Maximum Draw Down

The Maximum Run Up and Maximum Draw Down, calculated according to the Equity line of the system.

 

Regarding the Maximum Run Up:

  • In the case of long trades, it represents the maximum hypothetical gain that could have been obtained by selling at the maximum point of the curve, starting from the point of purchase.
  • In the case of short trades, the maximum Run Up represents the maximum hypothetical gain that could have been obtained by closing the operation at the minimum point of the curve.

 

The Maximum Draw Down is the opposite of the Maximum Run Up:

  • In the case of long trades, it represents the maximum hypothetical loss that would have been incurred if it had been sold at the lowest point of the curve, from the point after the purchase and before the scheduled sale by the trading system.
  • In the case of short trades, this is the maximum hypothetical loss that would have been incurred if you had bought at the peak of the curve before the hedging programmed by the trading system.

 

The Average Draw Down is a further element to analyze.

This is a parameter that can be useful for setting the stop-loss value.

As a general rule, you can use a double or triple parameter of the average Draw Down as a stop loss.

 

The Max Draw Down

The Max Draw Down represents the most considerable retraction that the Equity line has had, starting from a relative maximum.

This is a significant measure for assessing the risk of the system.

It is important to note that a series of consecutive operations compose the maximum Draw Down.

 

Return on account

Return on the account is the ratio of Net Profit to Maximum Draw Down.

It measures how much the trading system can earn against the risk of suffering the Max Draw Down.

The amplitude of the reference period, influence this parameter.

While the maximum Draw Down should always remain of the same magnitude, net profit should grow over time.

 

Average Trade

Average Trade is the average gain per trade. Don’t confuse it with the average gain of winning trades alone.

The first is an average calculated by taking as a sample all the operations carried out during the backtest.

The Average Gain takes only those closed for a profit.

 

This is a critical indicator because it makes it possible to assess the practical applicability of the system to the real market.

 

Average Trade Standard Deviation

Average Trade Standard Deviation expresses, on average, how much we can expect each trade result to deviate from its average.

Assuming that this phenomenon is distributed according to a Gaussian distribution, there is a 68% probability that trade results will oscillate between the Average Trade and the values​ obtained, adding and subtracting its Standard Deviation.

 

This probability increases to 95% if you add and subtract Standard Deviation multiplied by two.

 

Profit Factor

Profit Factor represents a summary index on the quality of the winning trades compared to the losing ones. You can compare it with the percentage value of the transactions in gain.

The basic rule is that the profit/loss ratio should be higher than 1.5.

 

Average Profit

The sum of all profits divided by the number of positive transactions is the  Average Profit Value.

The sum of all losses divided by the number of negative transactions is the Average Loss Value.

 

Average Profit/Loss Ratio, which is the ratio of average gains to average losses.

If it is greater than 1, it means that the system earns more than it loses for each trade.

 

Number of trades

This is the total number of trades in the backtest.

This indication provides essential information on the statistical significance of the data provided by the system. In general, it is necessary to monitor:

  • The total number of operations performed.
  • A total number of transactions closed at a loss.
  • The total number of transactions closed with profit.

 

Other elements include:

  • A maximum number of consecutive positive operations.
  • A Maximum number of consecutive negative operations.
  • The operation that generated the best percentage gain.
  • The operation that generated the worst percentage gain.

 

Average Gain/Average Loss Ratio

The Average Gain/Average Loss Ratio is similar to the profit factor.

The ratio is calculated on the average profit and loss values ​​and not on the sum of the profits compared to the sum of the losses.

Again, the minimum threshold is 1.5. 10.

 

Profit Percentage:

The Profit Percentage represents the percentage of transactions closed for a profit.

This variable is essential, both from an operational and psychological point of view.

If you have a too low percentage of winning operations, it can affect the confidence that is placed in the system.

Some systems have a profit percentage of less than 50% but still manage to produce profits thanks to a gain/loss ratio of more than 1.

[adinserter block=”12″]

Best/Worst Trade

The Best/Worst Trade displays the best single gain from the best trade and the worst only loss generated by the system, respectively.

It’s essential to understand the psychological impact it can have on the trader.

 

Time on the market

Time on the market identifies the frequency with which the system remains in position. In general, this parameter should have a low value, rather than a high one.

 

Peak to Peak and Peak to Valley

Peak to Peak indicates the time between two equity line highs (Time to Recovery).

It indicates how long the investor has to wait for his investment to review the new highs.

It is intuitive that the smaller this size, the better the underlying system.

 

Peak to Valley, on the other hand, is the time that elapses between a relative maximum and the next minimum.

 

This is the time conversion of the Draw Down:

the Draw Down measures the loss in % or currency, while the Peak to valley measures how long the Draw Down develops.

 

The intra-trade analyses

The most advanced platforms make it possible to carry out a particularly detailed analysis of the “intra-trade” performance of the system.

The price fluctuations that occur between the opening and closing of positions.

 

The Maximum Adverse Excursion

The Maximum Adverse Excursion, the maximum negative excursion that the price had before the system closed the trade.

In particular, an attempt is made to determine what is the maximum tolerance value beyond which, statistically, an operation then closes at a loss.

 

You can use this value as a stop-loss.

The Maximum Favorable Excursion, on the other hand, represents the maximum price favorable excursion before the position close.

 

It measures the maximum when the system has been profitable during each operation: you can use this value to identify an adequate take-profit.

 

Statistical Evaluation of the Trading System

 

Developing a trading system is not easy, and money management plays a primary role in the inherent risk of any strategy.

The first element of evaluation is the comparison with a benchmark.

 

This comparison allows us to understand if the system is creating value, compared to normal and passive Buy & Hold management.

Trading systems are, in fact, active management of money and, as such, must increase the profitability of the investment, or reduce its risk.

 

If you build a system that works on individual securities, the benchmark is the security itself.

If the system operates on an index-related future, the benchmark is the index itself.

The results of the system must also be subjected to further statistical evaluation tests to assess its efficiency, robustness, and significance.

 

Efficiency

To measure the effectiveness of a trading system, you have to divide the profit obtained with the potential theoretical profit.

In practice, it compares the actual gain of the system with that obtained by an ideal system, which would have bought on the lows and sold on the highs.

 

This should be compared with the time during which the system keeps the positions open.

For the same efficiency, the system that remains open for the shortest time should be preferred.

 

Robustness

Generally, an automatic system is robust when operating with a limited number of parameters.

Over-optimisation of a system occurs when a slight change in parameters is sufficient to cause a loss of profitability.

 

This happens when the parameters have been over-optimized, with the only result of identifying the best settings used in the past.

 

Significance

System test required numerous operations to be meaningful.

Significance is measured by the inverse of the square root of the total number of operations performed by the system.

 

The value obtained must be as low as possible (usually below 5%).

 

This formula shows that, to produce a 5% error, the system must have generated at least 400 operations during its test phase.

You can quickly evaluate results on more than 1,000 simulated operations in the intraday system. In daily systems, it’s challenging to obtain a large number of operations.

 

 

More from Finance Strategy System

Related Tutorials:

Breakout and Pullback

How to auto trade divergence

Key reversal pattern

EasyLanguage Tutorial

Ichimoku Indicator

ATR with Bollinger Bands

Moving Average Slope Trading System

Trading Intraday Nutrition

 

Wikipedia

Recent Content