Transcription
Have you ever wanted an answer to a problem, but no one can agree on anything? All right, here's the problem.
There are fake gurus out there who will sell you on secrets to making money that don't actually work. Worse yet, these gurus are proven liars who make their money from lying to beginner traders who don't know anything. No. On the other hand, there are YouTubers who call out fake gurus, claiming that patterns aren't real, and it's just a weird psychology thing with how people buy and sell. And it's the male equivalent of astrology. So, the question still stands, is it real or not?
Well, if we really want to put this to the test, we'll have to do it ourselves and build an entire market simulation from scratch. In a market, there are people who want to sell a product and people who want to buy it. If we throw a whole bunch of these people into a simulation, it'll create a little microcosm market. But right away, we run into a problem. How do these people make up prices? One person could make up $100 and another say $2. There's no rhyme or reason to this. To fix this, we'll use one piece of human psychology and then the rest of the video, I promise, will be math focused. We're trying to make this as unbiased as possible, but we need this detail here. So, if the price is $100, the new prices that traders pick will be up or down 1%. At a random value. So, if someone heard hot dogs are going for $5 a piece, it's pretty unlikely they'll suggest $50 as the next offer. So, our code makes a price like $4.95 the likely next offer.
All right, with a thousand of these traders in our simulation, it just kind of sits there. So, there's something called a maker, and they make the order in the order book, and then a taker who takes the order at whatever price is there. And if everyone is happy with the current prices, nothing's going to change. They just keep placing the same orders over and over again. And it looks like if nothing is happening, then maybe we do need psychology after all. Let's just give it a shot real quick. But I started coding up some new traders with different strategies. So we got random traders, but then we have trend followers who buy when it's going up and sell when it's going down. Something called high-frequency traders. They place buy orders below the price, sell orders above. And then whales who place these huge orders. Let's give it another shot. But even with all this psychology, it looks like it's impossible to get any long-term patterns to form. I honestly messed with this for a long time, but it just doesn't really resemble a market.
So, I think if we want to have any hope of proving whether patterns are real or not, we're going to have to try a different approach. So, since we're trying to stay away from psychology, let's focus on these random traders. We're trying to prove that patterns are math-based, not psychology based. So, if we can prove that patterns show up even when the traders are completely random, then we've actually proven there's no psychology needed whatsoever. But the longer I ran each simulation, the more this kind of stagnating problem would happen. Maybe the price would move a little bit up or down, but then it would just stop. Eventually, it would be kind of trapped in this like 1% range, which makes sense. The random traders only place orders plus or minus 1%. And so the 1% just stays the same no matter how long it goes. It's almost as if these huge walls on either side of the price kind of keep it from moving. And every once in a while when those walls were gone, we would see these huge price movements. But how do we get that? What we need is to remove the walls. So, in my code, I've had a 50/50 chance where an order is either a maker, where it just sits there, or a taker, where it takes the available offer. I figured at this point, maybe there's too many makers, which is creating the wall. So, I got rid of a few, and I didn't really expect much to change, but the price began to move, like a lot, and now it's making these huge jumps between existing orders. So, let's try zero market makers at all. And I I barely changed anything to the code, but this tiny change completely altered the simulation here. Look at this. All of these random orders seem to be slowly moving upward even though it should be random. And like remember our our traders are random. There shouldn't be any patterns here. So this is a real pattern in real markets and it's called support and resistance and our simulation is recreating it through pure mathematics.
Okay, let's run through some tests to see if these resistance lines show up more. All right, I'm checking it out, but it's not what I was expecting. Let me draw this real quick. So this sort of looks like nonsense, but if I bring over this, it looks like one of those trading diagrams. So, I've actually found a bunch of these and they literally play out according to the rules. In the real world, markets are driven by an order book. It keeps track of all of the available maker offers and that's really what we've coded into our simulation. But I'm curious what kind of an impact this order book has on the price. For instance, do the tops of charts have a huge order that's preventing the price from moving up? The only way to figure this out is to visualize the order book history. So, we'll draw out each one of these order bars and then we can make them more or less transparent based on the size of the order. Now, I have to rewrite my entire simulation so it runs on the GPU, but ever since I figured out how to do this, this is actually super easy. And honestly, you can run anything on the GPU. In Unity, the shader scripts end up using the GPU, so everything is just a shader. I've even written a neural network inside of a shader. And this was because I was trying to see if you could train an AI to make trades to make money. And that turned into a whole side project. But for now, we're still trying to figure out why exactly these patterns seem to show up.
Okay, take a look at this. This is sort of a weird U shape, but others would call this a cup and handle pattern. And everything about it, from the cup shape to the small handle, it all shows up right here. It's beyond fascinating that the patterns show up at all. Let alone they're the same patterns that appear in traditional markets. But my biggest question is still why? The inescapable prevalence of a phenomenon such as patterns kept sprouting up like a weed. It was like a rock that I just couldn't quite shake out of my shoe. But then it hit me. Since we've already ruled out psychology as an explanation because we're only using random traders, then there must be a mathematical explanation for all this. An explanation that had to be simple. Consider this chart. Now, technically, none of these traders care about where the price used to be. They place orders purely based on the current price. And at $100, they'll place a ton of orders around 100. Now, let's just say that price goes up to 120 briefly. The next time the market wants to move down to 100, there are all these new orders it would have to get through. Well, maybe it only hits 101 or 102 and it doesn't go below that. Well, the traders keep placing new orders around 102 because that's what they do. And a new slew of prices flood in. The next time price returns to this area, it has to get through 102. Well, this can happen over and over again and over time it can appear as if there is resistance. You get say three of these dips together and you can practically draw any sort of line through them. So technically resistance lines are a total mathematical principle. But more importantly, since patterns show up in our simulation, this means that patterns are really just extended support and resistance. You take all of these patterns and really you can extend everything and it's just these different support and resistance lines. So, in a weird way, we've proven that patterns are actually real.
Now, I'll be totally honest. When I set out making this simulation and this video, I did not expect this result. I genuinely thought that we were going to find out that patterns are fake, you know, and I was trying everything I could to make it not work. I tried introducing psychology and doing anything to show that the random trading would not create patterns. But nope, no, I just basically proved that in real life, the markets are driven by people who are just as erratic and unpredictable as a random number generator. In essence, most people have no strategy, no reasoning, and you perform just as well by randomly buying and selling, which solidifies that the reason patterns show up at all is based purely on how the order book fills up over time, not based on human psychology and people trying to predict the stock market. I mean, think about that. The fact that we can generate patterns that look identical to the stock market with a random nonsense trading means that most stock market traders are kind of bad at trading, which makes sense. There wouldn't be any money to be made if everyone was good at it. But I still find it so comical. So anyway, I guess that this means now we'll have to make an AI learn how to trade the stock market using patterns or something. I don't know.
If you want to mess around with this simulation, it's on my Patreon. The project has some buy and sell buttons that I've added so you can try to make money or lose money or you know do whatever with it. Oh yeah, I have a Patreon now. A special thanks to all these patrons who have already signed up. Thank you all so much. We also have a Discord, so join the Discord. I haven't even talked about it before, but quite a few of you have already joined. So come on over and hang out. We'll do some game jams at some point, work on projects together, and just send some good old memes back and forth. All my video projects are on my Patreon. I think I'm trying not to just dump the whole project onto GitHub, mainly because I'd rather make a gamified version of each video instead of making you build it yourself, you know. And and later on down the road, maybe I'll turn the fluid sim game into an app or something. I don't know. You don't know. We don't know. No one knows. So stay tuned because you might miss it. I'll probably miss it. Oh no, it's that tune again. I guess we're out of time. Bye. [Music]