Categories
Forex Education

The Do’s and Don’ts of Testing Multiple Algorithms

Is it possible to use different algorithms to trade in the spot forex market? This is one of the rarely thought of questions we are going to explore today. However, before proceeding any further, it is important to clarify why we use algorithms in the first place – we generally develop these systems through combining various indicators, money management, and trading psychology so as to be able to determine the most suitable moment to enter or exit a trade is.

Algorithms are thus complex combinations of various tools and information that need to endure rigorous testing processes (namely backtesting and forward testing) in order for traders to feel confident to use them in trading real money and a variety of market cycles. While some experts opt for employing the one best algorithm they have managed to set up, it is quite interesting to discover whether it would be possible or even necessary to make use of several different algorithms for the purpose of handling the natural forex market fluctuations and achieving the highest degree of satisfaction as a trader.

First of all, we should all understand that improvement or working on perfecting one’s algorithms should be made a priority due to the necessity to always increase the ability to extract greater benefits from trading currencies. What is more, we cannot but confirm that designing a better functioning algorithm is not only plausible but also performed regularly by a number of professional traders. We may one day find out how the algorithm we have been using does not respond well to specific market conditions, so the only way to tackle this challenge is to see how we can adjust our system and enhance our trading as a result.

Another important conclusion we need to reflect on concerns the systems we do have – if you are certain that you have something of value that you can truly use in trading, do not feel discouraged having a sense that you can do better. The key idea is to keep going and that improvement should go hand in hand with trading, as the two are complementary processes. Conversely, what you should strive to do is simply employ the strategies and indicators you have selected as the best-performing trading tools. You should feel relieved knowing that even when you take losses, your system will eventually weather through and give you positive results in the end. 

Many traders are excellent at following advice on how to test their confirmation indicators, as the first step in trading, which is followed by backtesting the entire system so as to finally reach the stage when one algorithm that is most likely to produce the best results is selected. Nonetheless, what often happens is for traders to realize that they have come across several well-functioning algorithms, causing confusion and doubt. In these cases, the algorithm which is the second in line is often quite close to the top-performing one in terms of the results it gives, which naturally awakens temptation in traders. Moreover, not only do they feel that the bigger is always better but they also feel that drawn to make use of the algorithm which is so close to the very top.

If you have two great algorithms in hand, which have exhibited similar quality during the testing phase, you are advised to use both of them by experts. The key condition here is to make certain that you have ensured proper assessment to form your judgment on correctness. While traders are not discouraged or dissuaded from employing the two best algorithms that they have accurately set up and tested, professionals insist that the two are used in two separate accounts and that they keep using the same algorithm for a specific currency pair in order to properly track the results. Therefore, if there are 28 currency pairs you can trade, do not use a single account employing one algorithm on EUR/CHF and the other on AUD/CAD just because you feel that they perform better with these pairs, as emotions have proved to get in the way of rational thinking and measurement. 

Once you do get into real trading and you experience real emotions, you may discover that one of the two systems simply outperforms the other. As this allows you to develop an extremely important insight into your algorithms, you do need to address them separately so as to make proper measurement and comparison possible. What is also important is that you allow them to go through the entire course any system would need to endure to be accurately assessed. This further implies that you would need to wait for a span of one or two years before you could draw any real conclusions. Only then will you be able to tell whether there is a definite winner when experts encourage traders to confidently shift all their trading onto that winning algorithm.

Once the winner emerges, traders are advised to move all the money from the second-best account into the best-performing one. At this point, we are no longer making assessments because this act is a matter of common sense that stems from obtaining organic results from real trading. Even if the difference seems minute, e.g. the first-placed algorithm gives you a 16% return where the other one is 3% behind year after year, you should understand that such discrepancy stands for the real money you could have put in your pocket. Furthermore, if you are unable to let go of one algorithm/account, you are in fact giving away the profit you deserve by clinging to having two systems for some unfounded sense of security. 

If you have experienced a situation like this in the past, you probably already know that human nature can be quite tricky. We may easily give in to the fear of making a wrong decision by allowing the doubt to creep in and delve inside our minds and hearts. Traders may for example think that the second system might become better with time, but this is most definitely a highly improbable scenario, and every attempt to avoid making the “difficult decision” only prolongs one’s torment and implies that more money is wasted instead of accumulated. 

In conclusion, traders are always encouraged to use two algorithms as long as they use it in order to define what suits them best. The selection of the best algorithm both takes time and requires some conscious, emotion-free assessment. Therefore, matters of feelings and convenience should be left aside as they cannot help anyone get the results they are looking for. You truly need to ensure clear measurement so as to allow for accuracy to occur, as without accuracy you will never actually fully understand your trading or manage to get the most out of it. Relying on multiple algorithms is then acceptable for as long as they serve the higher purpose – improving one’s trading overall. Use your systems in two separate accounts and wait for them to run their natural course to be confident about making the final decision to continue using only one of them.

While diversification is always seen as a positive action in trading, using two (or more) systems endlessly means that a trader is not fully aware of his/her priorities. You can employ diversification tactics in terms of spreading out onto different markets in the future, but in cases such as this one, making a definite winner is a matter of utter importance for the reasons we have listed above. Hence, if you have several algorithms that you know can be profitable, simply run them and measure your results accordingly. Although this process may test your patience and require you to make a final decision, you can rest assured that such discrimination will only help you reap the greatest benefits from trading in the forex market and allow you to secure only the most lucrative deals in the future.

Categories
Forex Videos

Forex Trading Algorithms Part 1-Converting Trading Strategy To EA’s & Running Tests On Profitability

Trading Algorithms –  An Introduction

 

Almost all traders, novices and pros alike, know at least the basics of technical analysis. Still, not many know how to convert a trading idea into a set of rules and then test them for profitability.  This video series aims to be an introduction to algorithms applied to trading. Even if you are not considering creating one EA or trading bot, we think it is very interesting to be proficient in converting your trading idea into formal code and test it. We will use mostly pseudo-code, but also python, a very easy-to-learn but powerful high-level language, and Easylanguage, developed by Tradestation, which is almost as pseudo-code because it was designed to be read as a natural language.

 

What is an algorithm?

An algorithm is a set of rules to perform a task in a finite number of steps. Basically, an algorithm is a recipe.

 

For example, if we were to create an algorithm to make a phone call manually. A possible solution could be this :

1.- Open the phone
2.- select the keyboard
3.- dial each number from left to right
4.- Click the green phone icon
5.- Hear the calling sound

6.- Busy tone?
    A- no ---> wait  60 seconds for the answer.
        Did somebody answer?
                Yes--> Start a conversation
                    I - Conversation ended?
                            Yes --> Hang up.
                No --> Hang up
    B- Yes ---> Wait 120 seconds and go to 4th step

Algorithms  used in Trading

There are many ways to create Trading algorithms, including advanced sentiment analysis, evaluating the words used in trading forums and news releases. Still, we will focus on algorithms for historical price action data series.

 The ability to create, test, and evaluate a trading algorithm is a terrific ability to own. This allows creating market models that map and profit from the market’s inefficiencies. If you happen to find one set of rules that historically made profits, it could likely continue making profits in the future. This is the basic premise of automated algos, expert advisors, and trading bots.

 

Algorithm properties

  • Inputs: zero or more values can be externally supplied. Some algorithms don’t need inputs, although the majority will, and of course, a trading algorithm will need to get timely data from the market to generate outputs.
  • Outputs: at least one result should be delivered. That is logical. The output may not only be a text. It can be a picture, a sound, or a market trading order.
  • Unambiguous: Each instruction must be explicit, with a single meaning.
  • Finite: It ends after a limited number of steps.
  • The algorithm should precisely specify what the computer should do. The computer is not smart. It is dumb. You should tell it precisely the action it has to make.
  • Effective: Every instruction should be basic enough to be made by hand or uses other algorithmic sub-units with the same property. Of course, the action must be feasible, which means the computer can perform that action because the instruction is included in the instruction set of the programming language you’re using.

The key to a good algorithm, as with recipes, is to break the ideas down into simple building blocks.

Flow Diagrams

Algorithms can be more complicated than a simple recipe. Besides, a recipe is interpreted by a (supposedly) intelligent cooker. On the other hand, algorithms are to be interpreted by brainless CPUs. Besides, algorithms usually accept a stream of data inputs, which must be transformed until an output or output is produced.  Flow diagrams are a pictorial representation of the algorithm’s process and data flow.

A Flow diagram is a very handy tool to develop your ideas into coherent algorithms because it helps you spot potential flaws and improvements and should be the first step before proceeding to the actual code.

 

In the next chapters, we will continue developing this basic idea, applied to trading, using trading examples.

 

Further reading:

The Ultimate Algorithm Trading Toolbox, by George Pruitt.