YouTube Video
YouTube Video Transcript
hey this is David for big bits in this video we’re gonna take a look at tuples on trading view in pond script and if you’re not familiar tuples are essentially just a predefined series of data or different data types that you’re going to be working with as if they were kind of like a single object and this probably is very confusing for those of you who are not programmers but if you are a more experienced programmer you might already worked with tuples or you might consider this kind of like a list of data but it’s basically a preset array but the array can contain different objects so let’s go back to the article that they give you here and here’s their definition tuple is an unchangeable sequence of values now in their case what we’re doing here is they are saving these float values and I’ll explain what this means and they are using these values in the security call to go back and plot the data on the chart so now what the update is that trading is done for tuples that I’m showing you here is they’ve made it available within the security function now tuples have been a part of pine for a little while but having it in the security function is relatively new and I’ll show you how that works here in just a moment now if you’re curious about tuples and how this actually kind of works you can go back and look at the pine script reference or the user manual here 4v4 it’ll give you a little bit more information but usually the best way to learn on this type of thing is to actually look at some examples now this is the exact code copied from this page here and I’ll show you kind of how this actually works so if you haven’t done the pine script tutorial series that’s probably a good point to start at so you can kind of understand what’s going on here but I’m gonna explain it to you here as best I can it’ll make more sense if you went through the pine script tutorial series though so I want to zoom into the chart run a four chart and with this script we are plotting the ohlc for for the daily on this particular chart so even though we’re looking at the four-hour the line is based on the daily values now the first thing that we do here is we create a function that is just going to return the open and the high values in a tuple so we’re actually going to use this function to set our open and our high values our onh variables in this tuple so we’ll call the security function for this ticker using the daily resolution and then the value we want we want that to be produced from this function and that function is going to just return the open and high in a tuple and that tuple is going to be assigned to these variables here so now our variables oh and H in that tuple are open and high now the same thing is done for the ln c the low and the close except you can see it’s explicitly writing out the tuple here for the low and the close but the thing that you need to pay attention to for the function here is that they are kind to kind of trying to stress that you can actually use a function here and instead of just actually doing explicit definitions here you can actually create your function and do some math and also return those as well so that’s something to be aware of and I’ll show you a little bit about that more later but as you can see these can be accessed individually you don’t have to do the brackets and extract the particularly durand a certain way you can just reference the actual letter or the name of the variable and it will access it like it would any other data type before so the tuples are just good ways to extract data all at once and I’ll give you a good example of that here in just a moment so yeah once again this is just the ohlc for for the daily on the 4-hour chart and we’re actually going to do a little bit more than that I’ll show you how those functions can be useful now the first thing I want to show you is using the functions you can actually use some of the built-in functions and of course there would be an issue I forgot to update that variable name let me save that again my apologies okay so what you’re seeing here is you’re seeing this 50 period moving average on the daily chart and you’re seeing this yellow 200 period moving average on the chart let me change that to red so it kind of matches my normal color scheme for my moving averages and we use the same security call using the current ticker but on a daily chart but for the tuple we are actually using a function in each of those particular assignments for the tuple so the first one we are going to call the built in simple moving average function using the closing price on the daily or 50 periods back and that’s giving us our 50 period simple moving average on the daily chart and the same thing for the second one except that’s the 200-day moving average so that’s one way to utilize these tuples and you were probably thinking well you know I I can do this anyway what is the benefit of actually doing it like this and the way that I would probably see myself using this at least in a more obvious way is similar to what we just did I have a script called the fancy triple moving averages and that is what I would probably use it for would be to extract the value for all of those in one line of code as opposed to doing three different security calls for each of these I would be able to do it with just one line of code now but you can see that the tuple now has three values being set at once as opposed to just the two and that should demonstrate that you can actually use any series value I’m not sure if there’s a limit on this or not I haven’t tested it out beyond the three here because that’s all I needed but you can see this based on my triple moving averages that I did in that indicator I’ve tried to have the colors match and we did the same security call we have one security call here for the 50 100 and the 200-day moving average on the 4-hour chart now if we switch this out to the daily chart the lines look a lot smoother because they’re actually designed for this resolution and you can see that the value should match up pretty well so yeah that’s pretty much all there is for tuples right now be have any questions about tuples please leave a comment otherwise hopefully this can help you a little bit with sort of minimizing your code it doesn’t necessarily have to be written like this if it’s easier for you to write your code the way we have been doing it in the tutorial series that’s completely fine you can do it like that as well in fact I’ll let you see that particular indicator and show you just kind of the differences up front so this is the fancy triple moving average indicator that I created let me go ahead and set these to the one day resolution so everything kind of lines up with the one that we just did okay so you can see that our lines overlap because these are also on the one day resolution with the same periods with the simply being average which is what you should expect and what’s really great is we confirmed that using the single security call here has the exact same values as what we had on the existing indicator which actually worked which should show you that the security call works really well with those functions within that particular security function that was a lot to say all at once but I’ll take you into the code here and show you really the difference you’ll notice there’s one line of code here which sets the first moving average there now I have a function for the ticker ID and the resolution there but I also had a function that returned that M a value if I wanted to convert this into a tuple and I’m not going to actually save this what I could do is actually do this set all three of my variables like that and I would want to copy this function and we will turn this into a to pool now in order to actually do this I’ll have to update the second set to make sure it says it’s working with ma two and the third set to make sure it’s working with m83 so hope you can see kind of how you could do this with just one line of code now now this may be pretty confusing which is why I didn’t do it in the tutorial series or really talking about it too much now but hopefully you can kind of understand what’s actually going on with tuples and actually how to use them just a little bit but that’s all for this video if you like the video please leave a like and if you like these types of videos or your interests in the pond script tutorials please subscribe because we’re gonna be going over videos like this and other information we’re trading you that can help you as well better than that thanks and have a great day [Music]
YouTube Video Description
< br/> ???? IMPORTANT LINKS BELOW ????
Tuples In Pine – TradingView Pine Script Tutorial/Update: In this TradingView Pine Script Tutorial we discuss how to use tuples to get and store multiple values at once with a single line of code. Recently, tuples have been made available as part of the security function in Pine. With Pine Script it is very easy for even beginners to create their own indicators or strategies that have many other indicators within them. Once we have completed the script, we can see our results immediately and begin working with more functions, indicators, and strategies.
??♂️??♂️??♂️??♂️??♂️??♂️??♂️??♂️??♂️??♂️
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!