String Arrays in TradingView Pine Script – Brand New Feature Update!

String Arrays in TradingView Pine Script – Brand New Feature Update!

YouTube Video

YouTube Video Transcript

[Applause] [Music] all right hey i am david for big bits and uh it’s been a little while since we’ve done a pure coding video but this is also an update video because we are using some of the new features that have been added to pinescript and tradingview and we are going to be looking at the array features that they have recently added which work with strings and i’ll go into that in just a minute but again for those of you all who haven’t already signed up for a premium account or just a paid account on tradingview if you’re interested please use the referral through my profile there should be a link in the uh description of the video that you can go and sign up on tradingview if you’re going to do that i’d appreciate if you use that link it gets you i think 30 worth of credits towards your paid plan as well but back to our array example that we have here you can see let me zoom in i have a label that’s being printed and we’re using some text here zero index first index second and last index zero index first index second last index and first index again so this will all make sense as to why this works we’re going to be playing around with the arrays to actually print this on here and i’m going to leave it up to you and your imagination how you can actually use this for something that would work well for you now let’s go ahead and check out their what’s new post here this came out on december 4th so it’s been a little while since i’ve been able to get around it this is about a week or two weeks almost now that this has been out but i did want to go over this uh go over a few things here and then we’ll get straight to the actual code itself now you can create more types of arrays so there is a line array and a label array and string array so string arrays are what we’re going to be working with there are label and line arrays now as well which are going to work very similar to the other arrays that are in there you’re just going to be storing these types of objects in there as opposed to just simple values that you’re used to these are custom objects a string is an object an integer is an object as well technically and you refer to those typically as data types whereas the labels and lines you’re probably more well it’s probably more common to refer to those as objects since that’s actually what you’re looking at on the charter these different objects so i just want to clear that up for those of you who aren’t as familiar with programming and i know i aim this channel towards those types of people so i just want to make that clear before we go forward now this is an example that we’re going to kind of start with we’re going to create an array a string array now this there are some options in here you can give initial values in your array and you can set the size of the array this is your index size so that is something to keep in mind as well you can specify the length of the array also they’ve added several functions for working with arrays and this is what we’re going to be working with i think it’s really cool feature that you can do with strings it’s going to be really helpful in certain areas when you’re creating your own scripts now the first one we have is array.join this one is going to take different array parameters and it’s going to return a string so we’re going to be working with a string array and we’re going to join those together and then after we join those together we’re going to split them back apart and get some data out of the split array so it should be pretty fun and we’ll actually show you how to do that within the function itself and there is another one here which is array.range that one we’re not going to touch because that one’s only for int and float arrays so we’re not working with those data types we’re just going to be doing uh string arrays so if you’re interested in learning any more about that i’d definitely recommend you check out the pinescript reference manual where well this is something we use a lot on this channel go back and forth to the reference manual you’ll see all of the different array functions that you can actually use there’s a lot out there we haven’t even talked about there’s a color array which i believe is very useful i should probably go back and update some of my old scripts with color arrays where we use different color values but let’s go and focus now on the actual script itself i’m going to walk you through the code and we’re not going to be writing this live here we’re not going to be live coding but we’re going to walk through step by step what we have here within our code so the first line here we create a new string array it’s very simple i don’t specify the length of the array and i don’t give it an initial value so what do i do to put the values in there you use array.push and i’m going to tell it we are using the array a we declared our array variable as a i’m going to push the value zero index into the array and it’s going to push it at the last index well this just happens to be the first index which is index 0 your arrays are going to be 0 index based so if you want the first item out of your array you’re going to have to call the zero index and that’s why i put the text in here zero index so hopefully this is a little bit more clear when we walk through the code we’re going to push the next one this one will be at the first index and it’s probably going to sound confusing but since it’s zero based index this was actually going to be at the one value in the index and then we’re going to do another one this will be our last one that we push and this is going to be pushed at the very end of the array again and this will be the second index and also our last index here so what i’m also going to do is i’m going to create another array well actually i’m going to create a string here excuse me j i’m going to call this j that is our joined string and what we’re doing is we are calling the array.join function that we talked about we’re using this on the a array where we have all of these values and the then we are separating them this is the separating value that we use we’re just going to do space dash space so give you some room in between them so you kind of see what you’re looking at when we create the label now we’re going to dig into this a little bit more but we’re going to start with our label the first thing we do we want to call the first value in our array and again since it’s a zero-based index we call the array.get function using our a array and we tell it we want the very first value which is at the zero index so we pass in zero so that one’s going to say zero index we move to a new line so it’s more legible then we do the same function we call the first index and then we call the second index so that should be all three of our items here zero index first index and our second index and let’s see what else we have here i have also on a new line added our join string which is going to show you that string that we added together with that separator value then probably the most interesting line or call here within this script is this particular line where we actually combine a couple of functions to call a single string now what we do here is we first within the get function so we’re going to be creating an array we’re going to be getting a value out of that now to create the array we are going to be calling string dot split so we are going to be splitting a string up based on a separator value so we know that we joined our array originally into the string j with the separator here we’re just going to use the same separator and i just checked to make sure that my head’s not in the way thank goodness you can actually see this and i haven’t been talking with my head in the way but anyway we’ve got our separator here and what we’re going to do is we’re going to split that string up so now within the get function we have an array that’s just temporary and it is the split array from our joint uh string from the original array so this is an entirely different array that’s being created in memory here and what we’re going to do is call array.get with that brand new array created on the fly here we’re going to get the first index which is going to be the middle value since we have three values and it should read first index on our very last line out of this and lo and behold we add this to the chart and that’s what you get we iterated through all of our array values within that uh string array we had a zero index first index in our second and last index then we added the new line where we showed our joined string with the custom separator value that space dash space you can see it displays it in order because it was joined now lastly we created that array on the fly and then we called to the array get to get the value out of there the first index which was the middle value out of the three so it’s important to know when you do the uh joins that it will keep them in order and then when you do splits it’ll also keep them in order if you do that one by one now there are cases where you might want to change their orders like i said there’s tons of ways you can use arrays and how you use them is up to you but just kind of pointing these things out to you so that you can actually use them going forward in the future now that is it for what we’ve done with the code here there’s a ton of stuff you can do hopefully we’re going to be making some more videos here soon on some of the other updates and some of the other features and hopefully maybe we can get back into some other things my schedule’s kind of cleared up just a little bit so hopefully we can get back to doing a little bit more videos now uh of course i did mention the pine script reference manual and then also go play around with some of the other arrays uh there’s a lot of fun things you can do with arrays especially when you start working with multiple arrays and yeah there’s just a lot to it there and you’re going to have to keep some of the concepts that we’ve worked on in the channel before in mind when you’re working with some of these values just to make sure that everything works the way it should now that is it for this particular video if you did like the video please leave a like on the video that helps a whole lot but if you like the video and you’re down there please go ahead and subscribe while you’re down there that way you’ll be updated on some of these other trading view updates and get some code updates as well on other things that you can work on and i should have some more videos coming out pretty soon there’s several updates from trading recently and hopefully we’ll get to all of those here but that’s going to be it for now thanks guys have a great day you

YouTube Video Description

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

String Arrays in TradingView Pine Script – Brand New Feature Update!: In this TradingView Pine Script Tutorial/TradingView Update, we discuss the new types of arrays added to Pine Script for Tradingview. This type of array has been requested for a long time and gives users the ability to work with strings in a way that wasn’t nearly as easy, or possible. This video we show how to use the new string array, but also how to join the array into a single string, and also how to split a string into an array. 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 #tradingview #pine #stocks #finance

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!