Calculating Slope in TradingView – Find Slope of any Plot

Calculating Slope in TradingView – Find Slope of any Plot

YouTube Video

YouTube Video Transcript

hey this is David for big bits and in this video we’re gonna take a look at finding the slope of a line in training people now this is actually something somebody had suggested so if you have any ideas for videos you would like to see about raiding the impound script please leave a comment for the video below but now we will get started on our slope now what the slope is is the rate of change essentially in this line now I have here the 50 period simple moving average and what we are doing here is we’re wanting to know the slope from one point to the next this is how we’re gonna start out we’re gonna look to see on this line what was the difference here what is our slope from one period to the next and to do this it’s very simple first we need to tell our indicator here that we are going to use an input for our moving average period so I’ve already got the moving average plotted up here with the fancy moving average indicator that I created and this is a 50 period simple moving average and we’re just going to calculate this again in our indicator here so that we can use these values to calculate our slope now the other input that we’re gonna have is a slope period so I said earlier we are going to calculate the slope from one point to the next well there is also the ability to calculate the slope from many periods back so we can take you know this point here to this point up here if we wanted to but we’re actually going to be working with the most recent one but going back through history it will do it for every single one so you’ll get the slope for whatever period we set at every point throughout the indicator now I’ve already calculated the simple moving average now to calculate slope this is actually really easy this is some pretty basic math stuff that you learned probably most likely in middle school and here is your formula right up here excuse me I’d scroll down a bit but this is your slope your rise over run you might remember that expression and really we’re taking the difference from our newest points which is the current price in the moving average to the previous price in the moving average so we’re going to use our smooth period to determine how many periods back we need to get the older price so we’re going to use the current price of the moving average versus however many periods back price of that moving average and then we are going to divide that by the difference of those periods and that’s just going to be our slope period so if we are currently at bar 2000 and our slope period is gonna be 50/50 bars back well we know that that would be 1950 we don’t even need to calculate this one all we have to do is just tell it it’s our slope period so that one is gonna be very simple to do and you can see we’ve already got that here on our top half we have our current price of the SMA minus the price of the SMA using our slope period back so on this particular example we’re going to be going from the most recent part of the simple moving average and calculating the slope from one period back now all we’re going to really do here is we’re just gonna plot this this is not gonna be an overlay because these numbers are gonna be very small and they should be you know somewhere under 50 for the most part no so let’s go ahead save our changes and add it to the chart okay I’m gonna go ahead and get rid of our code we’ll look at that again in just a moment though so let me move the chart so you can see a bit more okay so now you can tell we have our simple moving average up here but we have our slope for the previous period back here now one thing you’ll notice using a one period slope is that the line on the simple moving average always moves up when your value on your slope is above zero that should make sense as to why because you’re working with your rise over your run so if it’s a positive value that means your rise is going up and not negative number so your line will always be moving up when this value is positive so even though it goes down here during this segment it just means that the rate of change upward isn’t as high as it was before and the same can be said for the opposite where if you’re working with negative values as long as they are negative below zero the line is always moving down so that is how it works with one period so let’s go ahead and take a look and let’s use a 50 period slope okay so you can see this lines a lot smoother now and going all the way back we can take a look at this compared to the actual moving average so our current point is here and what we are getting is the slope of 50 periods back now with the fancy moving average indicator I have it set to highlight exactly 50 candles back or whatever our input was for our look-back period and we are looking back 50 here so we can see we are getting the slope from here to here so this should be a pretty substantial negative number and it is minus 51 so that is our slope here currently and let’s see you can tell this is a much smoother line because we are getting a slope for 50 periods back and it’s important to note when we look at the code that the way this works is that we have our slope calculating based off of the simple moving average we calculate it but not only that we our using the SMA and we’re telling it to look back however many periods we sit in our slope period so this is kind of redundant but essentially we started here and we’re looking back 50 candles and this occurred at every single point so even back here on this value it looked back from this point back 50 periods so that pretty much does it for this particular slope video I hope you enjoyed it and if you have please leave a like on the video and while you’re down there also please consider subscribing also check out my trading view profile you can see the fancy moving average indicator and some other indicators there have been several that have been quite popular and you can also if you’re considering a paid plan please consider to use the referral link because that could help both me and you get thirty dollars towards an upgraded paid plan so I appreciate you watching the video and that’s all for today thanks and have a nice day [Music]

YouTube Video Description

< br/> ???? IMPORTANT LINKS BELOW ????

TradingView Pine Script Tutorial: In this video, we discuss Calculating Slope in TradingView with Pine Script. We create our own indicator to calculate the slope of a 50 period SMA over the last candle, then we also show how we can easily re-use this calculation to find the slope of any period of time for the SMA we are using. In this case, you can replace the SMA with any other plot you like and calculate the slope with it as well. This was a requested video, if you have any requests please leave a comment with your idea.

??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️
Social and other public profiles
??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️??‍♂️
? Website: https://bigbits.io
? Discord: https://discord.gg/rapMn4z
? Twitter: https://twitter.com/BigBitsIO
? Facebook: https://www.facebook.com/BigBitsIO/
?‍?GitHub: https://github.com/BigBitsIO
?TradingView: https://www.tradingview.com/u/BigBitsIO

???????????
Referral links
???????????
? Buy, Sell and Trade Crypto on Binance.US with LOW fees: https://www.binance.us/?ref=35105151
?‍♂️ Want to buy crypto? Get $10 of bitcoin w/ your first purchase over $100: https://www.coinbase.com/join/johnso_dxz
? Sign up for a paid plan at TradingView and receive a $30 credit: https://www.tradingview.com/gopro/?share_your_love=BigBitsIO
? Browse privately and get rewarded with Brave Browser: https://brave.com/big406
? Receive bonus perks when purchasing Lightnite Game: https://lightnite.io/ref=BigBits
VIEW ALL HERE: https://bigbits.io/bigbits-referrals/

❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️
DISCLAIMER: All my videos are for educational and entertainment purposes only. Nothing in this or any of my videos should be interpreted as financial advice or a recommendation to buy or sell any sort of security or investment including all types of crypto coins and tokens. Consult with a professional financial advisor before making any financial decisions. Investing in general and particularly with crypto trading especially is risky and has the potential for one to lose most or all of the initial investment. In simple terms, you are responsible for your actions when trading.
❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️

#bitcoin #crypto #cryptocurrencies #tradingview #binance #binanceUS #coinbase

This channel focuses on Bitcoin, Ethereum, LiteCoin, Ripple, Link, Basic Attention Token and almost all cryptocurrencies that demand attention. Please like the video if you liked the video, and subscribe if you like these types of videos. David from BigBits is an experienced Software Engineer, but no one is perfect, If you find any issues with any of the open-source, free code, or code shown in videos please comment to let us know what to fix, we listen to our viewers!