STRATEGY Building Software
During my long experience in trading, both in retail and institutional, I have found that the most pressing topic is to go for unorthodox ideas to develop strategies.
Firstly, it is necessary to say that this topic is critical for trading. Of course, it depends on which market or set of markets you will develop the idea.
As mentioned in the last article, this is a fundamental aspect of strategy development. It is common in the development of strategies itself that, in principle, it is a matter of coming up with an idea of entry conditions and exit conditions.
In today’s age of high competition, it is not easy to come up with an unorthodox and exciting idea that has potential. As you already know, traders who have been watching the markets for years and years can relatively quickly learn to program in EasyLanguage and test their ideas on the markets.
Another option is to look for inspiration on the internet, in books, or in various training. In the last decade, machine learning technologies and thus available software, which can even generate trading ideas on their own, have also become widespread. Of course, we will not forget this interesting issue and focus on it.
We have to say that these “trading ideas” can be created based on:
- the price of the market,
- the price of other markets (for example, based on correlations),
- fundamental external data (announcements of companies,
- unemployment reports in the US,
- the sentiment analysis from internet, where we quantify news from articles, tweets, and various other publications into numerical form and evaluate whether it is a positive or negative message), etc.
It is essential to always keep in mind that entry and exit conditions should always have a clear inherent logic. Either way, these conditions should always be clearly demonstrated by robustness tests.
Shortly, we can have an infinite number of possibilities and ideas in trading. And that’s why it’s for the best to categorize your trading ideas clearly, straight from the beginning:
Types of signals
Types of data used
- Price data of a given market used to predict the same market
- Price patterns (Open, High, Low, Close)
- Indicators (Moving average, RSI indicator
- Price data of a different market used to predict the market
- Direct correlation of markets
- Indirect correlation of markets
- Fundamental data (unemployement reports
- Sentiment data (Tweets, News, etc.)
Methods of looking for trading ideas
o Market observation
o Ideas taken from the internet and books
o Machine learning technology (Genetic algorithms, etc.)
Going with the flow: Don’t demonize the latest technologies and let your computer look for trading ideas for you
The problem with discretional traders is their naivety. A vast number of amateur traders in this world falsely believe in nonsense signals. They learn different formations in price data, use some indicators. But if they code the strategy into an algorithm and test it, they find out, to their dismay, that it had probably never worked in the past.
They will find that no matter what “proven” idea they try, backtests will show the potential performance’s uncomfortable truth. I remember very well when I was in a similar situation. When I touched EasyLanguage and successfully acquired the ability to do necessary backtests, I was horrified to find that finding a strategy for any market seemed like a task for a superhuman.
But what now? While researching the internet, I came across one piece of software that changed my trading for good. It was 2012, and for the first time, I had the opportunity to try Adaptrade Builder software based on the principle of genetic programming. With the right software setup, I was suddenly able to generate many strategies at the speed of light.
Suddenly, finding a strategy was no longer an issue. But an entirely different problem arose: How to choose the right one from such a massive number of generated systems.
But let’s go step by step. Firstly, we will explain from the beginning the principle of how this software actually works.
Adaptrade Builder and the principle of genetic algorithms
If you want to work intensively on developing robust strategies, this program can save you a lot of time. This software generates strategy codes for the EasyLanguage language program in TradeStation or Multicharts (including codes for programs such as MetaTrader4 or AmiBroker) completely independently based on randomness combined with genetic algorithms.
In essence, this software automates the trader’s traditional approach to strategy development. In the conventional approach, the trader develops trading systems based on the assumption of how markets “work”.
Eventually, some modifications are made to the trading system by trial and error until the trader achieves acceptable results. Adaptrade Builder performs this process automatically. The program will generate the original population of trading systems thanks to a random selection of trading entry and exit conditions + orders.
This initial population is then “developed” through the generations using genetic algorithms controlled by pre-set performance criteria (so-called fitness functions).
The program builds trading systems on training, so-called in-sample data. Imagine you are training for an individual sport. You will find the best technique you can, and you will regularly achieve the best results with this technique. By analogy, imagine a trading system with which you acquire the highest profitability with the smallest drawdown on in-sample data.
Then there will be races that are not crucial for you (out-of-sample data). In these races, you will either confirm or refute that this technique (in our case, the strategy) is very well functional.
However, you still have to hone the technique because there will be more competition at the World Championships and the Olympics (live trading). Suppose the tests (robustness tests) confirm your functionality. In that case, you will use exactly the same technique that worked for you in training (in-sample) and race (out-of-sample).
Detecting a signal
An essential challenge in building a trading strategy is to find trading strategies that can detect a “signal” with predictive value in the future while ignoring any noise and random patterns.
It is necessary to realize that price data are non-stationary – the statistical properties of the data change over time. Therefore this task is a relatively large challenge for every trader. We determine whether the signal has a real predictive value based on Out-of-Sample testing.
The problem of the classical approach to building trading strategies:
Building automated strategies using genetic algorithms makes building strategies with Builder much faster and incomparably more efficient. Let us present you one clear example:
Imagine you have:
50 entry types with parameter values from 1-50
50 exit types with parameter values from 1-50
We want to test all possible combinations of entries, exits, and parameter values to find the best strategy defined by the so-called Fitness function, as already mentioned. How many possible combinations do we get?
50 entry types * 50 parameter values * 50 exit types * 50 parameter values =
As you can see, it is absolutely beyond human capacity to try a few thousand, let alone
Even for computers that today have multi-core processors, this number of combinations is very time consuming (months to years).
The genetic algorithms on which the Adaptrade Builder (Figure 1) program specializes solve this problem of too many possible combinations (trading systems) based on a random selection of a defined set of possible combinations and their subsequent improvement.
Figure 1: Adaptrade Builder software
Let’s explain both based on the previous example. We have:
50 entry types with parameter values from 1-50
50 exit types with parameter values from 1-50
Genetic algorithms randomly select different combinations of trading strategies (how many of them we will determine ourselves) and then improve them X times across generations within the In-Sample data. In the building process across X generations, we will also look for entirely new combinations to ensure the greatest possible diversification of strategies.
So what is the primary advantage of building trading systems using genetic algorithms?
Clearly, it saves you time. It increases the probability that when we can try a huge number of different combinations of trading systems, we will definitely find one with elements of robustness = that is, the ability to make money on the yet unknown Out-Of-Sample data.
In a shorter form, we will explain the process of strategy development using Builder as follows:
1. Import of price data with a defined trading session for a market or set of markets
As already mentioned, for example, the TradeStation platform has high-quality historical data that you can easily export to a text file. This file is fully compatible with Adaptrade Builder, which simply loads the price data file. In practice, we have a very good development experience for futures and stock markets.
Of course, Builder can also be used to develop strategies for Forex or cryptocurrencies. It’s also useful that you can develop strategies in a portfolio of different markets.
2. Genetics settings (GP settings) and Fitness function (Build Metrics)
We determine a lot of factors in the primary setting. A separate chapter could be devoted to this topic. However, one of the most fundamental characteristics is that in this process, we determine the size of the population and the minimum to a maximum number of generations through which we want to improve the strategy.
Additionally, we will determine the level of randomness and strategy crossing we will want to work with. We will be talking a lot about this topic in the future, so I recommend watching our videos and reading articles carefully. The concept of building strategies using genetic algorithms is phenomenal. Still, we need to understand it in depth to get the most out of it.
In the Build Metrics section, we slowly determine the most important things:
a) Fitness Function
By defining Fitness Function to Builder, we give instructions on what ideal statistical features strategies should be met when looking for them in the building process. In two words, it is primarily a combination of profitability, daily return stability, and the lowest possible complexity of strategies. Creating this mix of conditions for the building process is definitely part of every professional trader’s good know-how. The advantage of this software is that it can be done very efficiently.
b) Conditions For Selecting Top Strategies
In the Build Metrics section, we will precisely define the performance parameters that the strategy must meet to be stored in our database. We could then work with it and get its code and an overview of its performance, or we could apply stress tests to these strategies.
3. Stress Tests
Stress tests are performed to test the robustness of a business strategy. The robustness of the strategy means adapting to changing market conditions (perform well on out-of-sample data) and will still have the required performance – i.e., profitability and stability. We will discuss stress tests in detail in one of the next chapters.
When working with Builder, we decide whether we want to use stress tests during the building process itself or use them as a robustness test after building strategies.
4. Determining the basic characteristics of the strategy (Market Sides)
- Long / Short – Builder allows you to develop strategies on both sides
- Long Only – at the same time, however, we can only generate strategies for a long position
- Short Only – or vice versa to a short position
When choosing the development of strategies on both sides (Long / Short), it is essential to pay attention to the correct setting of the type of trading orders for relevant backtests. Be especially careful. We will talk more about this in the future on our website.
5. Strategy Logic
- Long/Short Symmetry
This section can determine if you want to develop a strategy symmetrically (Long / Short Symmetry) on both sides. The strategy practically mirrors its conditions for entry and exit, which is making the strategy much less complex, which is, of course, desirable. Besides, it would be difficult for you, for example, to develop a long-term strategy for stock indices while beating the buy-and-hold strategy. It is always necessary to think about the meaning of the development of the algo strategy. One of the basic principles is to beat long-term buy and hold investments, especially the stability of returns.
- Limit entries per day to (X)
An essential function that clearly determines how many times a day, we are willing to enter the position. In this case, we used a maximum of one entry per day to develop meaningful strategies. The problem with multiple entries per day is that you will find it very difficult to find strategies with Builder that can cover the high costs of slippage and commissions. The longer you hold an average position, the higher the Average Trade profit should be.
- Define the entry time range within a trading session from X to Y (Trade entry from X to Y)
Some traders like to define the time range of entries into positions. Of course, this time condition for entry may have its justification, but we have never used it much in practice. You can definitely find quality strategies in Builder without any time limitations.
- Exit after (X)
As part of the strategy, it is also possible to set the time date of the exit. We have never used this feature in strategy development.
- After opening a position, do not enter the next ones until the original position closes (Wait for exit before entering new trade)
This is one of the key elements. Without this option, Builder would develop strategies with a very chaotic and cluttered code. This setting is very important for creating simple strategies in principle. Remember, the less complex the strategy, the better.
– Among other setting options that we do not use is the possibility of applying Stop Loss in case of its use immediately to the same bar (Apply protective stops on entry bar). We definitely do not recommend using this setting, as you can never be sure whether a stop-loss has occurred after entering the position or not. So get your hands off this setting.
– We also do not recommend creating price derivatives, such as average averages, etc. (Allow nested indicators where applicable). This unnecessarily increases the strategies’ complexity, and we honestly don’t see any added value in creating these pseudo-indicators.
6. Indicators and Price Patterns
Besides other great advantages of Builder – one of them is the ability to choose from a relatively wide range of indicators that the software should work with.
But I would like to pay special attention to the possibility of creating price patterns. This program can work very well with price patterns and create very unconventional logics of entries and exits, which one would most likely not ever come up with, which brings an advantage in creating original strategies.
7. Determining entry and exit trade orders that Builder will work with when creating strategies (Order Types)
Builder allows you to determine whether you want to work with a given entry or exit conditions or just consider using it during the building process.
- Enter at Market
This is a type of order where the strategy enters a position at the market price if a specific condition is met. It can be practically anything you can think of: For example, the crossing of moving averages, the formation of a price pattern, etc.
- Enter on Stop
These are stop orders that add (for long) or subtract (for short) a certain price level (percentage, volatility based on ATR indicator, fixed dollar value, etc.). This type of order is also called breakout and is very popular among traders. It is trying to capture the price momentum and benefit from it.
- Entry at Limit
This is a type of order where the strategy tries to enter a position at a limit price (or better price) if a certain condition is met. Remember that in backtests, the limit prices are always theoretically filled in. Still, it doesn’t have to be in live trading, so the backtest might lose any relevance. Be sure to avoid this type of order. In the case of a functional strategy, all you need are market orders.
- Exit at Target
Of course, the Builder can also work with the classic profit target order. In practice, however, we do not use this type of order. Firstly, it works with a limit order (the issue is already explained in the entry to the limit). And secondly, it often reduces the strategy’s overall performance. Don’t forget: Keep your losses short and let your profits run. It works with percentage, volatility based on the ATR indicator, fixed dollar value, etc.
- Trailing Stop
The trailing type of Stop order is very popular in trading. It can be compared to intelligent control of the exit from a position. Many traders like the idea that if they make a certain profit, they move the stop order to the entry-level. Suppose the strategy is in a position on the right side of the market. In that case, we gradually move it in the direction of our desired trend. When the market then reverses direction and crosses this trailing stop order, the strategy exits a position with a controlled loss or profit. Of course, it depends on how the position of the strategies was managed. It is, therefore, a dynamically managed position based on the currently evolving market price. It works with percentage, volatility based on the ATR indicator, fixed dollar value, etc.
- Protective Stop
This is a classical type of protective stop-loss, where we try to control the maximum possible loss. This order does not react as flexibly to price developments in the markets as a Trailing Stop. On the other hand, this certainly does not mean that the order should inevitably be worse in performance. A different type of exit may be appropriate for each type of order. Again, it works with percentage, volatility based on the ATR indicator, fixed dollar value, etc.
- Exit After N Bars
One of the more specific types of position exits, which does not consider any market development price and simply exit mechanically, is the exit after x bars. We do not use this type of order exit in the form of market orders in any of our strategies.
- Exit After N Bars Profit/Loss
This type of exit from a position is slightly smarter than the previous kind of exit. It considers whether we are profiting or losing in the open position.
- Exit After Time
The time exit applies to intraday strategies and can definitely find its use among traders.
- Exit At Market
This is a type of order where the strategy enters a position at the market price if a certain condition is met. It can be practically anything you can think of: For example, the crossing of moving averages, the formation of a price pattern, etc.
- Exit End-of-Day
A very popular order for intraday strategies is an exit at the end of the day determined at the end of the trading session.
Thus, to approximately the extent, we will determine in the individual steps how to set up the entire process so that we can search for strategies effectively.
This software can be your great friend or enemy. You have to deal with potential selection bias and many other issues. Yet, it is a great tool to look for possible robust strategies. The truth is you need to have substantial know-how of how to work with this software carefully and successfully.
If you don’t want to read all I want to share with you article by article, grab our Ultimate Guide To Successful Algorithmic Trading here and read it anytime you want! 12 chapters, 112 pages: all in one place and completely FREE of charge!