Skip to playerSkip to main content
  • 13 hours ago
Transcript
00:00Hello everyone. Today I'm going to show you one of the most underrated technical analysis techniques.
00:05That has completely transformed my trading, which is calculating the moving average slopes.
00:10Most traders just look at whether the price is above or below a moving average, but they're actually missing a crucial information.
00:15The angle of the moving average tells you everything about the momentum and the trend strength.
00:20In today's video, I'll show you exactly how I calculate these slopes using Python. You will see.
00:25How I use them to identify trend strength, spot potential reversals, and make better entry and exit decisions.
00:30I'll also walk you through some real life examples so you can see this technique in action.
00:35I'm going to stop getting faked out by false breakouts and start identifying real trends with confidence.
00:39This is the...
00:40So let's just dive in.
00:44If this is your first time here...
00:45Welcome. My name is Vivek and I'm a financially independent algo trader.
00:48This channel is all about building a community of algo traders.
00:50We discuss everything about algo trading using Python, building and backlisting trading strategies, market updates...
00:55And much more.
00:56Please do visit our community website fabtrader.in.
00:58Also do check out my other YouTube channel fabtrader.in.
01:00Where I talk about my own financial independence journey and share tools, methods, and strategies.
01:05That helped me achieve my financial freedom.
01:07The code that I'm about to walk through is...
01:10As usual available on our community website fabtrader.in.
01:12You are familiar with this.
01:13So you can go into stories.
01:15And you would find the moving average slope.
01:17The article is pretty detailed.
01:19It gives you...
01:20Entire account of how this works, including the actual code is embedded here.
01:24And it also gives you...
01:25It gives you a couple of real world examples.
01:27And then most importantly, it tells you how to interpret the values...
01:30That comes out of the program itself.
01:32Right?
01:33So how to understand and how to interpret it.
01:35How do you find out, you know, what trend the particular stock is following can be made out...
01:40From this one.
01:41You don't have to worry.
01:42I'll also provide the link to this blog article.
01:45in the description as well as in the...
01:47I'll pin it on the comment section as well.
01:49So...
01:50You can always refer to that.
01:53Now let's jump into the actual code itself.
01:55I don't want to...
01:57To keep the video short.
01:58I don't want to spend a lot of time trying to explain...
02:00What moving average is all about and all that.
02:02Because I'm pretty sure you're already aware of that.
02:05So I'll jump right into the code.
02:06The code is pretty simple.
02:07It takes three inputs.
02:08One is your...
02:10The stock code.
02:11In this case, I'm using Yahoo Finance.
02:12So you would...
02:13The second input it takes is...
02:14What is the moving...
02:15Average window that you want.
02:16In this case, I've just kept 20.
02:18Because since I'm considering daily candles here.
02:2020MAs is basically a good measure of MA to look at.
02:25The third input is basically the slope period.
02:27How long do you really want to consider the data going back?
02:30In this case, it's going back up to 30 trading sessions.
02:32So it would basically calculate the moving averages for this...
02:3530 day period.
02:36And then based on that information, it calculates the slope.
02:39So to make this code work...
02:40You would have to install two dependencies.
02:42One is numpy.
02:43And the other is scikit-learn.
02:45Scikit-learn is again open source.
02:47I mean, typically people use it for machine learning.
02:49Especially when it comes to...
02:50If you want to work with classification, regression or clustering.
02:52It's one of the best and powerful tools available in the market.
02:55So the way code works is, we use a linear regression to...
03:00Figure out what the slope of the moving average for the time period that we already mentioned.
03:04And then it returns...
03:05It returns a slope value.
03:06And then depending upon the slope value, you can now figure out whether...
03:10The trend is either very weak, weak, moderate or strong or very strong depending upon the value.
03:14And also...
03:15If it's positive, it means it's an uptrend.
03:17If it's a negative, it is a downtrend.
03:18So I'll give you a...
03:19I'll show you a couple of examples...
03:20On how this works.
03:21For example, in this one, I've considered Infosys.
03:23Infosys, as we know...
03:24Stake...
03:25I've taken a nose dive here.
03:26So if you look at the output, the moving average slope value is actually negative.
03:30And it's showing a very strong downward trend.
03:33I'll also show you the chart.
03:35And we can check whether the code is working fine.
03:37So let's look at the Infosys chart itself.
03:39This is...
03:40Daily candle here.
03:41And then this line denotes the 30 candles, 30 day period.
03:45That we're talking about.
03:46And this is the 20 EMA.
03:47We can consider moving average EMA doesn't make a lot of sense.
03:50There are a lot of differences here.
03:51And this yellow line is basically the line that I drew.
03:55Which basically gives you an idea as to what the slope is.
03:58Which pretty...
03:59Indicates that it is a...
04:00Pretty downtrend.
04:01Look at the way it has taken a nose dive here.
04:03So that way the code seems to be working.
04:05And then giving you the right results.
04:06Now let's take a look at another example.
04:08This time, what about the...
04:10Up-trend bonds.
04:11For example, Bachach Finans is in the news all the time.
04:14It's quite famous.
04:15Now this...
04:16This...
04:17When the entire market seems to be going downhill...
04:20Finland seems to be like a racing horse.
04:22You know.
04:23So it's an interesting case.
04:24So I've taken Bachach Finans...
04:25Here.
04:26And then rest of the inputs remain the same.
04:27And then when we run it, we get a positive 30.
04:30Which is pretty steep.
04:31And then it's also showing a very strong upward trend.
04:35Based on the value.
04:36Right.
04:37Let's take a look at the chart now.
04:38There you go.
04:40That's the Bachach Finans daily chart.
04:43And then this line that I had connected.
04:45From these 30 days start of the moving average to the end.
04:49Denotes the...
04:50Overall angle in the trend.
04:51This stock is going.
04:52Which pretty much is very clear.
04:53That it's a very strong upward.
04:55Trend.
04:56So...
04:57We've tested both scenarios.
04:59The court and the court.
05:00Seems to be working well.
05:01So that is how exactly the court works.
05:04You can refer...
05:05To the blog article where it explains how to basically infer the data.
05:09The slope value.
05:10Or the angle.
05:11And then accordingly.
05:12How do you find out the trend.
05:13So you can read through this blog article for more details.
05:15So how I personally use this is basically I don't use this as a standalone.
05:20Indicator.
05:21You should never do.
05:22As any good algo trader would tell you.
05:24You would have to use a...
05:25Confluence of indicators.
05:26Do not take just one indicator.
05:28And trade with it.
05:29You typically look for...
05:30Information from multiple sources of indicators.
05:32To ensure that you are in the right direction.
05:33You are making the right trade.
05:34Right?
05:35That increases your success of your trade.
05:38To a higher degree.
05:39So...
05:40I typically take this also into account.
05:42Whenever I am getting into a trade.
05:43For example, if I am getting into a long trade.
05:44I would really...
05:45I would really want to check if the slope of the moving averages are all aligned.
05:48In fact, there are strategies...
05:50That I use.
05:51Where I use multiple moving averages.
05:52And then I check the slope of every moving averages.
05:54To ensure that all of the...
05:55Are indeed pointing towards a particular direction.
05:57That I want to take the trade into.
05:59So that...
06:00That is one way I use it.
06:01Or sometimes if the slope is very steep.
06:03In the case of the Bajaj winners that we talked about.
06:05I typically tend to avoid taking a trade.
06:07Because anything that has a very steep slope like that.
06:10Tend to reverse with a vengeance.
06:12So...
06:13You will have to be very careful.
06:14So you can actually use...
06:15This tool in multiple ways.
06:16To ensure that...
06:17You know...
06:18Your whole success of the trade improves.
06:20In the next video.
06:21I will take this concept that I have just explained.
06:23And then...
06:24Show you a small...
06:25Small utility that can...
06:26That can do a screening.
06:27Of any stock universe that you want.
06:29And give you a list of...
06:30Top up trending.
06:31Or the down trending stocks.
06:32From that universe.
06:33If you genuinely found this video useful.
06:35Please consider subscribing.
06:36And liking the video.
06:37And I will see you soon in another video.
06:38And until then...
06:39Take care.
06:40And happy trading.
Comments

Recommended