Algorithmic Trading Tips 17.

BUY AND SELL ORDERS, POSITION SIZE AND STOPS.

PART 1: THE TOOLBOX FOR SYSTEMATIC TRADERS.

This issue contains five modules for the development or testing of a trading strategy in Tradesignal. An entry, a position size control and different stop types – modules allow quant traders a quick and easy start in the development of algorithmic trading strategies.

WAtCH VIDEO NOW. (4 minutes to improve your performance.)
DOWNLOAD WORKSPACE. (For users with Thomson Reuters.)
DOWNLOAD WORKSPACE. (For users with Bloomberg.)

By downloading you agree to the terms of use below.

One of the great advantages of Tradesignal is the ability to develop and backtest trading systems quickly – even without programming knowledge or statistical studies. The algorithmic trading software provides hundreds of predefined examples and almost every indicator is included in its textbook format. If you look for the moving average for example, you will find all trading strategies associated with this indicator quickly and you can display all entry and exit signal on the chart. Therefore, many ideas can already be translated into action by using the prebuilt strategies.

In this Algorithmic Trading Tips edition, however, I’d like to present to you my private tools which will make your strategy development even easier.

01. THE ENTRY-MODUL.

Let us start with a test trading strategy which is responsible for the entry signals. It is based on a simple moving average and the Slow Stochastic Indicator.

The strategy is exemplified in two parts: First, the trend direction is determined. To place a long trade, the market must be above its rising moving average (SMA). If that is the case and the Slow Stochastic crosses above 50, the actual entry is triggered on the close of the next bar. This two-part approach ensures that many signals are generated in the trend direction. This will be advantageous if our position is eventually closed early although the trend is still intact. Thanks to the oscillator the next entry signal in trend direction is just a few bars away.

Figure 1 shows the pure entry signals on the chart. One necessary improvement can be seen too – the size of the position.

THE REASON BEHIND THIS: Backtest results will be heavily distorted, if you trade a market that fluctuates by more than 50% with a fixed position size all the time, then simply by higher absolute price levels a contract at 10,000 points would have a higher impact than a contract which is bought at 5,000.

BY THE WAY: If you enter the command drawline(slowk(5)) into the command line of Tradesignal, the Stochastic indicator is displayed below the chart. You can then add a line at 50 to visually get a clear understanding of how entry signals are generated.

FIGURE 1: ENTRY SIGNALS.

The entry module generates long and short signals based on a rising SMA and the Slow Stochastics Indicator.

02. THE POSITION SIZE MODULE.

The position size can easily be defined by the next script. It invests the same amount of capital in each trade signal. Thus, the influence of the absolute price levels is compensated.

On the following chart you can see the result: With every trade now EUR 100,000 are invested in the DAX (as you can see the size varies for each buy or sell signal). This prevents distortions in the backtest due to the high volatility of the underlying market.

FIGURE 2: ENTRY SIGNALS WITH POSITION SIZING MODULE.

In order to eliminate distortions due to different levels of price levels, the position sizing module is used, which employs a fixed capital amount for each trade (100.000 Euro in this example).

03. THE INITIAL STOP MODULE.

What stands at first glance while looking at the chart, is the lack of a stop loss. Although the entry strategy opens a position in trend direction at some time, as you can see in Figure 2, the strategy has long been caught in a short trade for a while. Use the following code to insert an Equilla initial stop into the strategy. The width of the stops can be controlled in the properties section – either on an absolute or a percentage level. In addition, visuals will (and this is the case in all scripts) also appear on the same chart, where the strategy places the stop.

INITIAL STOP (ABSOLUTE).

INITIAL STOP (PERCENTAGE).

FIGURE 3: IMPLEMENTATION OF AN INITIAL STOP.

In the present example, a stop module has been implemented. The cash stop risks an absolute amount of 10.000 Euros.

04. THE PROFIT TARGET MODULE.

If the position is hedged with an initial stop, you can take the next step the following scripts to realize the accrued gains. These are, in each case, a simple profit target – either in absolute or in percentage terms. Please note that the absolute profit target is for the overall position, and not for individual contract to which it applies.

PROFIT TARGET (ABSOLUTE).

PROFIT TARGET (PERCENTAGE).

As you can see, the use of the oscillator initially described brings a clear benefit here: In 2013 the profit target has been reached twice, but the entry-level logic has brought the system back into position quickly.

FIGURE 4: USING PROFIT TARGETS.

In this example, a profit target has been added to the modules already included. It performs a profit-taking on reaching a freely definable absolute profit level.

05. THE TRAILING STOP MODULE.

In addition to the use of a pure profit target, protecting accrued gains without realizing them with a fixed barrier can also be a rewarding exit strategy. The following Equilla code allows you to use such a trailing stop.

NOTE:
Please note that when applying the exits Tradesignal always automatically takes the exit, which is closer to the current market level. If we add another five percent stop loss into the chart above, the stop remains five percent below the entry price, until a gain of more than five per cent has been reached. In this case, the 10 percent trailing stop would be closer to the market than the initial stop and would be gradually trailed into the absolute gain range.

FIGURE 5: USING A TRAILING STOP.

In order to achieve a continuous hedging of accrued gains, a trailing stop is used in this example. With this tool, trends can be optimally utilized.

 

DEVELOP AND TEST YOUR ENTRY STRATEGY USING THE MODULAR PRINCIPLE.

With the presented modules you can test the robustness of any entry idea in a simple manner. Without “crunching numbers” you can adjust the correct parameters visually. Don`t pay too much attention on the results of the strategy at this stage of system development, but rather on whether the signals are plausible or not.

As you can see on Figure 4, a trailing stop of 10% is a good choice for this market and entry style. A much smaller trailing stop would not exploit the trends, while a much further stop would not protect profits enough. I prefer to find out the first parameters for a potential further optimization in a visual way rather than by stubborn optimization. Therefore, all presented scripts show where you place the orders.

A workspace including this indicator can be downloaded.

That’s it for today – take care, take profit and “auf Wiedersehen”.
Philipp Kahler

DISCLAIMER.

© Copyright Tradesignal Ltd., London.
Distribution allowed under a Creative Commons Attribution-Noncommercial license
 http://creativecommons.org/licenses/by-nc/3.0/

Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is specifically prohibited. All other protected brands and trademarks mentioned in this document conform, without restriction, to the provisions of applicable trademark law and the copyrights of the respective registered owners.

Tradesignal Ltd. obtains information from sources it considers reliable, but does not guarantee the accuracy or completeness of its information contained therein. Tradesignal Ltd. and its affiliates make no representation or warranty, either express or implied, with respect to the information or analysis supplied herein, including without limitation the implied warranties of fitness for a particular purpose and merchantability, and each specifically disclaims any such warranty. In no event shall Tradesignal Ltd. or its affiliates be liable to for any decision made or action taken in reliance upon the information contained herein, lost profits or any indirect, consequential, special or incidental damages, whether in contract, tort or otherwise, even if advised of the possibility of such damages. This material does not constitute an offer or a solicitation of an offer or a recommendation to buy or sell securities. All expressions of opinion are subject to change without notice.

This code is provided free of charge and “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of fitness for a particular purpose and noninfringement. In no event, shall Tradesignal Ltd. be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, or of or in connection with this code or the use of this code.

.

accumsan felis mi, nec dolor. vulputate, velit, Nullam Praesent felis id,