The Scientific Way to Test Technical Analysis — Transcript
Full transcript
- 0:00Does technical analysis actually work?
- 0:02Some traders swear by it. Others think
- 0:05it's a complete nonsense. The problem is
- 0:07that technical analysis isn't one single
- 0:10method. Every indicator, pattern, and
- 0:12trading rule makes a different claim
- 0:14about the market. David Erensson's book
- 0:16called Evidence-based Technical Analysis
- 0:18demands a stricter approach. Define a
- 0:21rule clearly enough to be tested or
- 0:23accept that it isn't useful at all. The
- 0:25rule must then be evaluated
- 0:27statistically to determine whether its
- 0:29historical performance shows real
- 0:31predictive power or is merely the result
- 0:33of luck. This is called rule
- 0:36significance testing. In this video,
- 0:37we're going to understand how rule
- 0:39significance testing works, why a
- 0:42profitable back test isn't enough, and
- 0:44then use Python to define a trading rule
- 0:47and run a significance test ourselves.
- 0:49Before we can test a trading rule, it
- 0:51needs to be objective. For example,
- 0:53imagine someone says buy when the price
- 0:55bounces off the trend line. And the
- 0:57reason is different traders may draw
- 0:59that trend line differently. They may
- 1:01also disagree about what counts as a
- 1:03bounce unless those decisions are
- 1:05defined precisely. We cannot test the
- 1:07rule consistently. Now compare that with
- 1:10a rule that says go long when the 50
- 1:12period EMA crosses above the 100 period
- 1:15EMA. We can write it in Python, run it
- 1:18on historical data and get the same
- 1:20signal every single time. This does not
- 1:22mean the EMA rule is profitable. It
- 1:24simply means that we have a clear claim
- 1:27that can be tested with evidence. A
- 1:29profitable back test does not
- 1:31necessarily mean that the rule can
- 1:33predict the market. Imagine a strategy
- 1:35that randomly generates long only
- 1:37signals throughout a powerful bull
- 1:39market. It may produce an impressive
- 1:41back simply because prices are broadly
- 1:43rising, not because its signals contain
- 1:46useful information. It simply benefited
- 1:48from the direction of the market, not
- 1:50from its ability to predict it. There's
- 1:53also another problem called data mining
- 1:55bias. If we test hundreds of different
- 1:57trading rules and keep only the most
- 2:00profitable one, the winner may simply be
- 2:02the luckiest one, not the most
- 2:04predictive. So instead of asking only
- 2:06whether the backis was profitable, we
- 2:09need to ask a better question. Is the
- 2:11rule actually useful or did it just get
- 2:14lucky? We begin the assumption that the
- 2:16rule has no predictive power. This is
- 2:18called the null hypothesis. The rule
- 2:20produces one of three signals on each
- 2:22candle. Long, short, or neutral. A long
- 2:25signal is represented by + one, a short
- 2:28signal by minus one, and a neutral
- 2:30signal by zero. Each signal is then
- 2:32compared with the market return that
- 2:34follows it. Before evaluating the
- 2:36signal, the market's overall trend is
- 2:38removed. This is called dtrending. D
- 2:40trading prevents a strategy from
- 2:42receiving free credit simply because it
- 2:44stayed long during a rising market or
- 2:47short during a falling market. Next, we
- 2:49use bootstrap simulations to generate
- 2:51thousands of result representing what
- 2:53chance could produce if the rule had no
- 2:56real edge. Finally, we compare the
- 2:58actual rule with those simulated
- 2:59results. The result is expressed as a p
- 3:02value. For example, a p value of 0.03 03
- 3:06means that if the rule had no real edge,
- 3:08luck alone would produce a result this
- 3:11good only about 3% of the time. The
- 3:13lower the p value, the harder it is to
- 3:15explain the result through luck alone.
- 3:18But this does not mean the strategy has
- 3:20a 97% probability of being profitable.
- 3:23The p value only tells us how unusual
- 3:26this historical result would be if the
- 3:28result had no edge. For example, let's
- 3:30get started with an actual back test
- 3:32result. So take a look at this. It is
- 3:35generating more than 400 in P&L. The
- 3:38annual return is more than 2,000. The
- 3:40win mean rate is 65% and the sharp ratio
- 3:42is 3.17. So looks awesome, right? And
- 3:45this is also the equity curve of the
- 3:48actual portfolio when we compare to the
- 3:50benchmark which is the price of BTC USDT
- 3:53over this period. So you might think
- 3:55this result actually looks good. But
- 3:56before we jump into conclusion, we have
- 3:58to consider the fact that price of BTC
- 4:00itself was also going up. So even a buy
- 4:03and hold a strategy would have made
- 4:05money. So that begs the question, does
- 4:06the strategist code have some real edge
- 4:09or is it just pure luck? And in fact, if
- 4:11I show you the code for the strategy,
- 4:14you can see in the shoot long method, we
- 4:16have this. So it's not exactly a random
- 4:18function, but it is making decisions
- 4:20based on the time stamp of the candle.
- 4:23We're not even considering the price at
- 4:25all. So of course, this strategy does
- 4:28not have any edge. But again, when I
- 4:30look at the result of the back test, it
- 4:32looks good. It's going up. So, how do we
- 4:35make a final decision? Well, that's when
- 4:37the rule significance testing comes in
- 4:39hand. So, if I show you the next result,
- 4:42this is for a rule significance test
- 4:44over Jess's dashboard. Now, by the way,
- 4:46as always, I'm using the Jesse framework
- 4:47to do my analysis. And specifically for
- 4:50this use case, I'm using the UI
- 4:52dashboard version to show you the result
- 4:54of the test, but you do not have to use
- 4:56this. You can also use the research
- 4:58module of Jessie which provides the rule
- 5:01testing completely for free. And on this
- 5:03page, you can also see some example code
- 5:05in Python. Now, while that's going, I
- 5:07want to quickly remind you guys about
- 5:09our Telegram. It's the fastest way to
- 5:10get notified about my future work,
- 5:12whether it's a new tutorial or a tool
- 5:14that I create. Also, don't forget to
- 5:16check out our free Discord where more
- 5:18than 5,000 members like you and I are
- 5:20hanging out there and helping out each
- 5:21other with algo trading so we can all
- 5:23succeed together. The links for both are
- 5:25down in the description. And you can
- 5:27also ask Jess's MCP to run the tests for
- 5:30you. In fact, that's what I did. So, I
- 5:31just asked it to write both the
- 5:33strategies and run the rule tests for
- 5:35me. And at the end, it just gave me the
- 5:37results. So, I just clicked on them and
- 5:39then I was inside the dashboard seeing
- 5:41the results as I am right now. So,
- 5:43anyways, looking at the result of the
- 5:44test, we can clearly see that it is
- 5:47failing. So, it says so right here. So,
- 5:49the result is not significant. And if
- 5:51you take a look, the observed mean of
- 5:53the actual back test is sitting almost
- 5:56in the middle. So it definitely is not
- 5:58beating these simulations at all. To be
- 6:00more precise, we want a p value to be
- 6:03less than 0.10. But even that may not be
- 6:06great. So preferably we want it to be
- 6:09below 0.05.
- 6:11And the smaller this number is, we will
- 6:13have more confident in the result that
- 6:15we are seeing. Now let's compare the
- 6:16same exact period with this one. So this
- 6:19one also has an equity curve that is
- 6:21going up. It is the exact same time
- 6:23period. So the market was going up
- 6:25during this time as well. So again,
- 6:27we're going to have to ask the question,
- 6:29how do we ensure the result is not luck
- 6:32and that the strategy actually has some
- 6:34edge. So before I show you the result of
- 6:36the rule significance test, let's take a
- 6:38look at the strategies code. So this one
- 6:40is actually defining some indicator. So
- 6:43a fast, a slow one, the ADX indicator,
- 6:46and the dungeon channel. So the inter
- 6:48rule of the strategy is actually
- 6:51meaningful. So it is saying that
- 6:52whenever a crossover happens here and
- 6:54the ADX is above good threshold and the
- 6:57current price is above the previous
- 6:59dungeon channel upper. So basically we
- 7:01are also checking to ensure whether or
- 7:03not a breakout is happening. That's only
- 7:06the time that we actually want to go
- 7:08long. So this one actually makes sense.
- 7:10And these are some strategies that
- 7:12researched in the past by so many
- 7:14people. And when we take a look at the
- 7:16results of the rule testing for this
- 7:18one, we can see that it says it is
- 7:20statistically significant. The p value
- 7:23is below 0.05.
- 7:25And if we take a look at this chart, we
- 7:27can see the observed the mean of the
- 7:30strategies return is indeed an outlier
- 7:33and it is not sitting like in the middle
- 7:35or something like the other one. So
- 7:37again, this was the previous one, the
- 7:39one that isn't passing and this is the
- 7:42one that is indeed passing. But if you
- 7:44are using Jess's dashboard, you can just
- 7:46look take a look at this part and it
- 7:48will tell you whether or not it is
- 7:49statistically significant or not. And by
- 7:52the way, in case you want to actually
- 7:54run this test yourself, this is the form
- 7:56of this is dashboard. So you choose an
- 7:58exchange a time period, you pass a
- 8:01trading route which asks for the symbol,
- 8:03the time frame and the strategies name
- 8:05and then we give it the number of
- 8:06simulations and that's it. Then you just
- 8:08press start and it will begin. Now these
- 8:11days if you have watched my previous
- 8:12videos you know that I'm doing almost
- 8:15all of my research using Jesse MCP. So I
- 8:18just ask it and give it a prompt and it
- 8:20start the research for me and at the end
- 8:22it just gives me the result inside just
- 8:24dashboard. So I click on these URLs then
- 8:26I'm able to just take a look at them and
- 8:28whenever I'm asking it to write a
- 8:31strategy I always say that hey like this
- 8:33is the type of strategy that I want but
- 8:35before moving on I need you to run a
- 8:37rule test and then move on with the back
- 8:40testing and then optimization and then
- 8:42Monte Carlo simulations. So basically
- 8:44the rule testing is the first thing that
- 8:45I need the agent to do for me right
- 8:47after writing the strategy because if
- 8:49the rule test is failing there's not
- 8:51even a point in running a back test for
- 8:54the strategy in the first place. And
- 8:55lastly I know that guys these days we
- 8:58are not used to reading books anymore
- 9:00especially if it's such a long book such
- 9:02as this one. But I genuinely enjoyed
- 9:04reading this book and it changed how I
- 9:06looked at trading indicators altogether
- 9:09because you hear all the time that
- 9:10whether or not a specific trading
- 9:12indicator works or not. But in fact, all
- 9:15we need to do actually is to just run
- 9:17these tests to get an answer ourselves.
- 9:20So I definitely recommend reading this
- 9:22book if you haven't already and
- 9:24definitely begin writing rule tests by
- 9:26yourself and run them. They are very
- 9:28easy but very effective. If you enjoyed
- 9:30the video, please give it a like and
- 9:32subscribe to the channel if you haven't
- 9:33already. I plan to create more tutorials
- 9:35just like this one. Thanks for watching.
- 9:37I'll see you in the next one.
About this transcript
This page contains the full transcript of The Scientific Way to Test Technical Analysis by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 1,881 words across 264 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.