TradingView Pine Script Tutorial 31 – Using Fill Function on a Chart. Part 4: Meaningful Gradients

TradingView Pine Script Tutorial 31 – Using Fill Function on a Chart. Part 4: Meaningful Gradients

YouTube Video

YouTube Video Transcript

[Music] hey this is David for big bits in this video we’re gonna take a look at gradients from one more time with our fill function in pond on trading view and this time instead of just creating a nice pattern we’re actually going to be giving them meaning or some importance to the gradients so that you can actually look at the chart and tell that the gradients actually are showing you detail or information about the indicator you’re working with instead of just looking nice like the repeating gradient pattern in the last video which if you haven’t seen will do a very good job of explaining how we get the gradients on the fills whereas this video we’re gonna focus on the importance of the transparency and the colors that you’re actually seeing on the chart itself so I have pulled up right now the color gradient framework and I referenced this in the last video as well this is the pond coders account their mod on trading view they have several scripts that are very good to reference when you’re looking for these sorts of things the color gradient is really nice the framework that they did has two different modes and I’m going to be showing you a different mode for the actual gradients now the first one they use is in advance and decline now that would be this particular film method and you can see here that when the difference between the two moving averages is increasing the gradient gets more opaque and less less transparent and you can see when that difference between the two moving averages decreases it continues to become more transparent and similarly we have these gradients on the RSI I believe that is down here I forget what they said it was with it might be just the histogram on the MACD though but anyway the relative mode for the gradients takes into account strength of the values around it before and so what you’re gonna see here is that they don’t always continue going down in a very very much predictable way as you would if you just look at the chart here and you knew that the moving average we’re getting closer you could tell you could know exactly how much the grading is whereas here it’s a little bit more relative so it’s a little bit more flexible I should say as opposed to the advance in decline now I should say you can take a look at their code if you are a new or an intermediate programmer it it’s probably gonna be challenging for the new programmers but if you’re intermediate you’ll probably be able to figure it out once you look at it for a little while but for those who are more advanced programmers it’s gonna make complete sense if you go through the entire script and you get down to where they’re actually plotting things now what I wanted to show you was the gradient pattern that I came up with which is based on the strength of the difference in the in the fill so what I mean by that is so for example move this over here or we’ve got a better example so for example here you know similar to the advance and decline method that the pine coders account used what I’m looking at here is the strength of the difference so whenever we have a cross over the moving average the difference whatever that is it’s always the same as the maximum difference between the two so as the continues to climb at the beginning the difference between the two is always at its maximum value until finally the difference between the two moving averages becomes less than the maximum difference like it was right here I would say that was the maximum difference at this point in the green cycle and you can see the difference continued to go down and we are tracking the difference where this is the difference is in reference to the maximum difference on the moving averages now you can see here it continues to widen and it approaches the maximum difference which was back here and you can see it starts to get less transparent and continues to become more transparent here as it narrows and you can see here it sets new maximum differences as it gets very wide on the fill here and it quickly approaches the transparency full transparency as it gets ready to cross over you can see it starts getting brighter and brighter on the red and back to transparent so it’s always going to approach transparency before the cross over and it’s gonna be depending on how you have them set up it could be very quickly now let’s actually take a look at the code and I’ve actually kind of set up our code here to where we’re using a bit more of the coding styling guide that they have on the pine coolers website we’re gonna try and stick to that going forward just to make sure that you know we’re following their standards so that if somebody in the community is also following their standards we’re also going along with it so then people look at our code they can also read it as well so it’s gonna take a little bit to get used to and I’m gonna have a video coming up soon about that so just look out for that but for the most part if you followed along through the whole tutorial series at this point you should know what we’re doing it’s just basically changing where we are doing certain things in the script and how they are being named essentially how we’re declaring the variables that’s about it okay so we’ve added a couple of inputs since the last video these are just for our moving average length and I haven’t bothered to give them a title or anything we’ve also added our citation in here which is where we have copied the code over from the gradient framework from pine coders and we made a small change since we are working with percentages instead of just using numbers 10 through 1 we are actually going to be using numbers 1 through 100 or 0 through 100 because we’re working with percentages now we also had to come up with a function to determine where we are relative to the maximum amount so in our fills our maximum amounts let’s say let’s look at this one this stands out a little bit better our maximum width is right here we’re fully opaque now when we’re here our current distance between the two let’s say is 5 just for an example and our maximum distance is 10 back here we’re getting the percentage difference like relative to where we were to the maximum so if our distance here was 5 and our distance here was 10 our difference would be 5 which is 50% of 10 so what we’re going to be doing there is we’re actually going to be returning this number because the G value is greater in 40 but it is not greater than 50 so it’s gonna return this value which is pretty much in the middle of our alpha gradient that we’re using based on that function now if that was confusing at all please go back and watch the previous video where I explain that a little bit more as to what all of these numbers mean here now we do have to declare several variables as well we have to keep track of the maximum difference since our crossover so whenever there’s a crossover we start keeping track of a new maximum difference and then we also have to keep track of our current difference we don’t actually have to keep track of it to reference it in the past but we do have to instantiate that variable so we can use it later and then also we have to have a variable to calculate and store our current percentage difference that would be the 50% value here now the logic on this is very simple and that is just that we are gonna check for a crossover if there is a crossover we’re actually just gonna reset our maximum different cents equal to the current difference and we skipped over this my apologies but the current difference is always the absolute value of the MA one – MA – so you’re always gonna get a positive value there because we’re measuring a distance or a length those are always positive values now of course when I say we have the crossover we’re setting our maximum difference equal to our current difference because this is the first difference we’ve had in this new series with the crossover and the same goes with the cross under as well and unlike the previous video we don’t have to keep track of the direction we’re going we can know that just by knowing that we haven’t had a new crossover and we are still under still below and we do that in our plot down here but otherwise if this isn’t a crossover and this isn’t a cross under the only thing left to do is check to see if we have a new maximum so while these numbers are getting farther and farther apart we continue to update the maximum difference say it was six back here seven eight nine ten it continues to update so our max difference here was still 10 because it didn’t increase anymore but our current distance was 5 so that’s how we got our 50% difference we talked about earlier now that is really about all there is because then we called that function that I mentioned for the percentage of which returns based on our current value and our maximum value relative percentage to where it is on the maximum amount so on that 5 and 10 example it was 50% that function is going to set our current percentage difference equal to 50 in that instance and then all we have to do is plot so this is actually very simple to do the logic is very easy to read in my opinion especially compared to all the functions and the gradient framework and that’s very good work and it’s very advanced and it looks a lot better than what I have here let’s be honest this is mostly just green all the way and a couple of bars that aren’t aren’t so green but if you’re wanting to capture strength relative to the maximum value this is a very easy way to do that now of course we have our plots and then the last thing we do of course is our fill function which is last four videos here have been about now and this is going to be the last one on fills for a while hopefully because I think everyone has had their fill of fill right that was a horrible pun ok so we have our fill we’re plotting one two and of course we know the color based on whether or not ma one is above two and then we return and green if it is and red if it isn’t we pass in the percentages now since we changed these values to have a zero and the singles digit and move the six or the ones that should over to the left we now can reference those versus their percentage values so really that’s all there is to this particular video and I do want to go back to the PI encoders example because it does look much better than what I have here and I’ll probably end up publishing this particular script so you can see it and you don’t have to copy it by watching the video so keep a look out for that on my profile you can always check that out it’s in the description of the video below so if you haven’t checked it out please follow me there that’ll help you out to keep up to date with what I’ve posted the color gradient framework let’s go back to that and check that one more time you can see I think it’s a little bit nicer because our values stayed much more opaque for much longer here in our moving average differences so I believe this looks a little bit better although it would still kind of be nice to have it somewhat opaque because it kind of completely disappears here so there are drawbacks and benefits to both methods I would say but it’s all very nice it makes your chart look a lot nicer and one other thing that I wanted to mention before the video is over is that you should consider thinking outside of the box here these gradients we are working with what we see we see a moving average and another moving average but what you could do is actually use another indicator to give you your gradient values so for example let’s take the relative gradient you could use this relative gradient from the MACD or the RSI whatever they chose to use and you can actually put that gradient between the moving averages so you kind of combine the two into one particular indicator now if you don’t want to see that I can do that but really all there is is doing exactly what we did but instead of plotting the difference for the moving averages you just plot the differences for the other indicator the MACD or the RSI so I hope that helped if you like this video please leave a like and check out the profile of course and while you’re down there hopefully you’re giving it a like if you haven’t already please subscribe because if you like this video there are plenty of other videos very similar to this where we cover two we’re wheels for tradingview in pine script we also talked about some of the things on the channels such as crypto and crypto related projects because that’s something that I like now you can also please check out if you’re considering a paid plan on trading view please consider using the referral link in the description of the video that will help you get $30 and myself $30 towards an upgraded plan and that is really nice to have in my opinion so if you’re considering that please look at that but other than that I think that is it for this video we’ll have another one soon like I mentioned we’ll talk about the styling guide or the coding style guide in another video soon hoping to have a few other things out in the meantime and it may be a week or so before we get another tutorial video out we’ll see how that goes but for the most part things are moving very well and I appreciate every one of you who are watching all the new videos and have kept up with everything so far I really appreciate that but other than that thanks and have a great day [Music]

YouTube Video Description

< br/> ๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป IMPORTANT LINKS BELOW ๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป๐Ÿ”ป
๐Ÿ“ˆ Sign up for a paid plan at TradingView and receive a $30 credit: https://www.tradingview.com/gopro/?share_your_love=BigBitsIO

๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ
Relative URLs:
๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ๐Ÿ“ฐ
๐Ÿ—ž https://www.tradingview.com/script/rFJ5I3Hl-Color-Gradient-Framework-PineCoders-FAQ/
๐Ÿ—ž https://www.pinecoders.com/coding_conventions/

๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ
Social and other public profiles
๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ๐Ÿ™‹๐Ÿผโ€โ™‚๏ธ
๐Ÿ’ป Website: https://www.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!