Vollständiges Transkript von „I Built a Profitable Trading Algorithm (20 Years of Backtest Included)“. Klicke auf einen Zeitstempel, um das Video an dieser Stelle zu öffnen. Du brauchst ein anderes Video? Nutze den YouTube-Transkript-Generator.
0:00 in today's video I'm going to talk a little bit about algorithmic trading the reason I'm making this video is because the other day someone asked me if chat GPT was going to revolutionize the world of trading and I said that the short answer to that question was no he was of course talking about chat GPT being able to produce some trading algorithms I said no because chat GPT doesn't have the appropriate AI structure to build trading algorithms chip is a natural language processing model these models are specialized in the interaction between humans and computers very useful for a wide variety of things but not so much for trading if you want to develop trading algorithms you need to use specialized software which is the easier and more limited route or you can learn
0:48 how to program and learn the relevant literature on quantitative Finance AI for trading and so on which is a much harder route but of course provides more freedom and it's potentially Limitless in today's video I'm going to show you one of the options of specialized software you can use to build trading algorithms the software I'm going to use is called strategy Quant it's a software that allows you to build trading algorithms without worrying about the programming part instead you can focus on the process of stress testing the algorithms you build which is the difficult part about this as you'll find out by the way this video is not sponsored I actually bought a license of strategy qu a while back so what I'm going to show you comes from my actual
1:33 experience with it I will show you several things I learned when using this some great things and some limitations as well strategy Quant uses an optimization algorithm called genetic algorithm to find profitable trading strategies a genetic algorithm basically mimics the process of natural selection meaning random mutation and crossover in living organisms but it does that to trading algorithms roughly speaking the process goes like this strategy Quant will build a population of random trading algorithms based on several parameters you can choose this initial random population is not necessarily good or profitable it just serves as a start from that point the genetic algorithm will apply the process of
2:19 random mutation and crossover which are elements of natural selection to optimize this initial population of trading algorithms towards a goal defined by the user for example you can optimize strategies towards the minimization of draw down and the maximization of profit so what I'm going to do now is to actually build a trading algorithm for the eurusd 1 hour time frame based on roughly 20 years of data and then I'll make some observations and conclusions about the whole process this is the user interface of strategy Quant and as you can see here there are a lot of parameters you can change but of course I'm not going to go into detail about this each one in this video I already selected some parameters previously I'm going to start the
3:05 evolution process and as strategies begin to emerge they will appear at the bottom I selected one of the algorithms to show you a few interesting things you can see the monthly and yearly performance of the strategy the whole list of Trades and the equity curve you can also export
3:53 this as a code for trade station metatrader and j4x and you can see the pseudo code as well to understand what the Alor ithm is doing going back to the equity curve notice here that the space between white lines represents one year so the strategy would have performed very well for over 20 years one important detail here is that you can see that the data is dividing in two parts the left part is what's called insample data which is the part of the data that is used to optimize the strategies the right part is the out of sample data this is actually the first robustness test the greatest enemy in algorithmic trading is called Curve fitting it's actually pretty easy to build a strategy that has a nice looking back test like this but once you start
4:38 stress testing it you can see that the strategy but would not survive in a real environment for a variety of reasons the out of sample test is a first filter to test this strategy in unknown data as you can see here the strategy continued to perform well in the out of sample part which is a good indication this is actually the important part of developing algorithmic trading strategies people often look at a back test like this and they assume this performance is supposed to continue like this forever that is not true building the algorithms is the easy part the real work is stress testing the algorithms performing The Walk forward runs optimizing the algorithms and building a portfolio of algorithms that minimize
5:24 the standard deviation of returns what follows is a brief list of robustness tests that must be performed in order to ensure that a trading algorithm can be used in real markets number one is the out of sample testing this is the first test to evolve this strategy in one part of the data and test it in the remaining part to see if the performance holds if the strategy cannot perform in the same way in the unknown part of the data it can be dismissed number two is testing the algorithm in other markets and time frames testing the algorithm in other markets is considered to be a strong robustness test if a strategy works well in more than one market it has a much lower chance of being curve fitted this
6:11 is a very rigorous test if it tests 100 algorithms in other data usually only one or two will pass this test ideally you want algorithms that capture some fundamental edge of multiple markets not algorithms that only work in specific markets and time frames number three is the walk forward test walk forward testing is used to discover the best way of optimizing strategy parameters and also the best period of optimization walk forward tests are much more important than back tests as I said earlier there is continuous monitoring and optimization in trading algorithms they are not as s and forget alternative number four is the Monti
6:56 Carlo simulation multi Carlo simul ulations will take the list of Trades and randomize their order and also randomly skip trades to see how that affects the overall performance an algorithm must be able to have enough consistency if you will to survive this randomization process number five is the what if simulations what if simulations can tell what will happen with the performance if you decide for example to increase slippage the spread or simply avoid trades at a particular time of day or day of the week the point I'm trying to make here is that building the initial algorithms is the easy part the job of a developer is to stress test these algorithms walk them forward and optimize them in the
7:42 best way possible that is an ongoing process there is no set and forget solution this leads us to a series of very important conclusions about not only algorithmic trading but also discretionary trading in general and trading performance the number one is the Dynamic nature of markets and performance even though the algorithm performed well over 20 years there's absolutely nothing that stops IT from collapsing from now on the reason is because markets react to predictions and even subtle changes in market conditions can render an algorithm like this useless for this reason best performance is never indication of future performance that's the case in systematic trading and in discretionary
8:27 trading as well in reality what happens is that algorithms have an unknown expiration date due to the ever evolving environment of financial markets once again there are no set and forget Solutions conclusion number two is the systematic trading involves discretion and vice versa as you were able to briefly observe the process of building and testing trading algorithms requires a significant degree of discretion on the part of the developer the opposite is also true this discretionary trading cannot work properly without an objective framework that is grounded in the appropriate modes of action of diverse Market participants this means that systematic and discretionary action are not mutually exclusive they are
9:14 interdependent in reality what happens is always some form of hybrid trading where some degree of objectivity and subjectivity must be combined the question is how heavily the trader will rely on each one conclusion number three is systematic action and the problem of perception it's important to note that in the case of price action analysis which is the only form of visual market analysis objective Frameworks cannot always be automated despite being objective that happens because of the problem of perception which can be condensed in the words of the German philosopher Emanuel Kant you cannot extract out of sense data the mechanism to make sense of sense data that is also observe in the coastline Paradox in
10:01 fractal geometry where there is objectivity in measurements but subjectivity in the choice of measurement tool that's relevant to price action traders of course because price is fractal that's especially unfortunate for Price action Traders perception is obviously not a problem in quantitative modes of market analysis conclusion number four is that there are no Solutions only tradeoffs Traders are initially attracted to Al algorithmic trading because they want to avoid the enormous list of cognitive biases present in discretionary trading but they don't realize they will substitute these problems for new ones and these new problems associated with machine learning stress testing walk forward optimizations and so on are far from
10:48 being simple and easy to deal with in basic terms trading is always difficult no matter which road you choose so you must pick your poison so to speak and deal with it Con conclusion number five is that trading is hard until you find out it's really hard everyone is looking for a basic setup or strategy to trade consistently but if that was possible all of this I just demonstrated would simply not exist there would be no motivation to go after complex trading strategies if a simple one was enough so everyone trying to tell you that this is easy it simply lying but of course there's a lot of people willing to believe such lies even while knowing deep down they shouldn't believe that creating all these videos and courses
11:33 that show you the real side of things requires a lot of time and effort if you want to support my work please consider purchasing my courses in ebooks the audience of this video might be particularly interested in the institutional trading ebooks you can find their official release video in the video description or in the video card the audience of this video might also be interested in my latest fractal trading mastering price action and Beyond course you can find the official release video in the description or in the cards as well if you're interested in bundles or discounts send me an email at support fractal flowpro docomo like the videos I produce please consider clicking the like button
12:18 subscribing to the channel activating the notifications leaving your feedback in the comment section and sharing this video with your trading Community thank you very much for watching and take care