TradingView Pine Script Tutorial 16 – Getting Started With Scoring

TradingView Pine Script Tutorial 16 – Getting Started With Scoring

YouTube Video

YouTube Video Transcript

[Music] hey this is David for big bits and in this video we’re gonna take a look at a new type of indicator that we’re gonna be covering here and that is essentially combining multiple indicators which we’ve already done but in this particular indicator what we’re gonna do is we’re gonna create a scoring method and the indicator is going to use points based on the different indicators were using to help us determine when a good time to buy might be or just how confident the signal to buy it might be so to get started the first thing we’re gonna do actually I make a new script so click on the pot editor if you don’t see it on your charts stand here at the bottom pull it up go to new blank indicator script we’re going to start out with an indicator now this is what you’re gonna start with here there’s really not much to it we’re just naming the indicator the study if you’ve seen the other videos you’ll know what the study means and you’ll know what plot does as well but plot pretty obviously just plots whatever you want on the chart so in this case if we were to save this indicator and add it to the chart it would plot the close which is the current price or the end price of each candle now let’s go ahead and name this scoring development now I’m gonna kind of do some live coding today for this video in particular mostly because I had a very complex scoring script or indicator that I made and I realized I need to break it up in a smaller segment so this video is actually going to end up being about three videos worth because there’s a few other concepts that we’re gonna cover that need to be covered in their own video and we’re gonna build from this particular indicator that we’re starting with today which is a very simple example of how the scoring is gonna work and then we’re gonna move into one that’s a little bit more complex and go over some other parts of pond script that’s gonna help you with other things and hopefully do some things you haven’t really thought of before so let’s go ahead and say this as scoring developments excellent let’s name it like let me copy some code over here from my other screen just a moment we’ll just rename this copy that so what we’re going to be doing and this particular indicator is we are definitely not going to be plotting the clothes price I’m going to go ahead and erase that because we don’t need that at least not yet what we’re gonna be doing is we’re gonna be taking a look at three different ways to judge what’s going on on the chart so we’re going to look at the price we’re gonna see if the candle is green or not because usually if you’re looking for a bounce then you want a green candle and like I said this this may or may not be a good strategy we’re just getting started here I just want to show you so let’s pretend that if it’s a green candle it’s worth let’s see five points or something like that and if we have the fifty period SMA which I have on the chart if it’s moving upward then we’ll give it a few points because we’re in an upward trend now the other one that we’re going to be doing is the RSI and we’re gonna be taking a look at is we want to give more points for RSI the lower it is now one of the things we’re gonna cover in the future videos is how do we handle times like this where you can see on the chart where the RSI bottom dad here but the price continued to drop even though the RSI went up now you might look at that and call it a divergence but what you really want to do is you want to quantify that somehow in your scoring and I think I found a way to kind of help with that it doesn’t necessarily identify it exactly but the scoring method that I’ve come up with that I’m gonna show you in the last part of the videos for scoring will kind of help you account for the price continuing to go down even though RSI bottomed out a few candles ago but for now we’re just gonna focus on trying to capture a low RSI as a more valuable points and in that case means it’s gonna be worth more points on our indicator so what we’re gonna do is we’re actually gonna build an indicator kind of like our artists eye model here except it’s not going to bounce between 0-100 like RSI it’s gonna be on its own chart here that’s why the overlay is set to false and it is going to range from zero to whatever number of points it adds up to so we could add up to ten points it could add up to a million points just keeping things relative in scale all right so now that I’ve explained everything and hopefully you’re still watching the video I know I normally show you an example that’s why I said these videos we’ve made it a bit different so let’s go ahead and start by calculating our RSI and we’ll name this RSI set the RSI sets the clothes value for a 14 period that’s default and I’m not putting in the inputs right now like we have in the past and that’s basically just because this is first one and it doesn’t really matter if it’s hard-coded we’re just doing this for an example now the other thing we want to do is we wanted to check for it if it was a green candle or not so we’ll name this one is green and I actually need to go back and change these and we’re gonna use a condition which is the parentheses if you compare two values within the parentheses this condition it’s going to return true or false so we’re gonna set is green to true or false by comparing the clothes making sure it is greater than the open so let me go back I want to rename these I hate working with lowercase it’s just something I’ve gotten used to I typically capitalize all acronyms and use camel case with my other variables so after we get that we also wanted to look at our SMA 50 period to make sure these comments match all right I’ll call this SMA and then we will call the SMA built-in function with the closed with a 50 period so now we have our values and let’s actually go ahead and plot these plot the RSI we’re gonna plot is green and we’ll also plot the SMA the reason I’m gonna plot is green is because it’s a true or false it might show a one or a zero but I haven’t even tried plotting of a boolean value on here before so we’ll just save this oh yeah I need to capitalize those my apologies that’s part of the fun of doing this kind of live coding even though this is a recorded video I am NOT going to go back and edit this stuff out that’s too much work all right that’s been saved let’s add it to the chart okay so you can see our SMA up here that’s following along with this value of course it’s not on that chart because we set the overlay equal to false now the RSI is down here and you can see it’s this number and let’s go to the last candle here it’s forty six point zero six and on the smooth RSI right here you’ll notice it’s also forty six point oh six so it’s the same calculation that we’re using there now that we know that I’m gonna go ahead and get rid of that RSI we’re going to quit plotting the simple moving average just because it throws things way out of scale and now we can see the RSI now the first thing we’re going to do is we’re going to start coming up with our points now the first thing we’re gonna score is going to be if the candle is green so let’s call this one is green points and let’s set that equal to we got to do a condition here is green so if it is a green candle then we are going to give it let’s see how many points did we say I think it’s at five let’s just do three and if it’s not green then we’re not gonna give it any points that’s fair enough so if you haven’t seen my videos before this is checking this condition and if it’s true it returns this value if it’s false it returns this one we’re setting that value here okay go on to the next one first let me go ahead and add some notes here green points we’ll do the SMA points now and we’re going to have a condition here to check whether the current SMA is greater than the previous SMA and I’ve covered this in the past and one of the most recent videos and that is we are working with an array the simple moving average is a series of data you can see it on the chart here in order to access the previous values back here when we’re looking at the calculated values we have to supply it an index number to go backwards so the current candle is always index based zero that’s the way arrays work so if we want to go back one candle we have to say we’re gonna use the SMA one in the array that’s the first one back so that’s how we get the value of the previous one so to know if the SMA is moving upwards we have to check if the current SMA was above the previous SMA one period back it’s pretty simple so once we check that condition if it is true we’ll give it another three points if it is false we’ll give it zero so now we have points for our green candle we have points for a upward moving trend now the interesting part is really capturing the value of the RSI so we don’t really care about giving points to the RSI if it’s above a certain level I mean obviously if it’s up this high then it’s already up too high man we probably don’t want to buy there with our indicator we don’t want to give these points to signal a buy so what we’re gonna do is we’re going to have a limit and then we’re gonna go under now we’re gonna start with I believe it was 35 I used in my testing let me double check that yes so we’re gonna look at only candles that have RSI under 35 and how do we do that so it’s actually really simple how we calculate these points and what I’m gonna do I typed on the wrong page what we’re going to do is we are actually going to give one point for every the value the RSI is below 35 so for example if we’re looking here and the value is 23 if it rounded it to 23 we rounded down to 23 that would be worth 12 points because it is 12 below 35 likewise if this rounded down to 20 it would be worth 15 points here because it is down at day 20 and 15 below 35 let’s go ahead and type that in now we’re gonna check we have to have the RSI below 35 at 35 it should be worth zero and we need to have no wait I think that’s all we need for right now excuse me I was getting a little bit confused in my code so if it is below 35 then the value we want to return is 35 minus the RSI so if the RSI like I said was 20 rounded down on this particular candle that we’re looking at 35 minus that 20 it would leave us with 15 points so that means the lower the RSI is the more points we’re giving to our particular indicator here to show is when to buy you know it’s not gonna be ideal when we plot everything out and you’ll see that but I hope I know you’re kind of getting the idea of what we’re trying to do here we’re trying to give us some confidence values on the indicators that we’re looking at and plot that on the chart so that we can see when we’re most confident on making a decision on what to do so if it is not below 35 it obviously needs to return zero so now we have all of our points what do we need to do with our points well quite frankly we just need to total the points up so we go to make a new variable total points set it equal to is green points plus SMA points plus our RSI points now we have our total number of points what’s also plot our points fix this comments all right so we have RSI I’m actually gonna leave that on there for now let’s plot our total points and set the color equal to color dyed yellow because we have a blue or s I already save that you can see it applied the changes to the chart now what you’re looking at on the yellow line is our total points for each particular candle based on the settings that we gave it now we’ll go ahead and look in depth at one in just a moment just to make sure the calculations add up but you can see what the RSI once it got really low here below 35 there was kind of a mirror effect on the point system because as RSI went below 35 it popped up in reflection to the moves that were happening there so let’s go ahead and take the RSI off because that might be a bit confusing and it China kind of changes a scale that we’re working with now we can see something that looks a lot more like the actual point system it’s not really flat looking like it was in the previous picture but you can see there are high points so when the price dipped low here you got more points than before and let’s actually take a look at this particular one we do not have a green candle so we should get 0 points for that it’s below the 50 period all right so it has zero points and it has 14 point seven one points that means the RSI was fourteen point seven one points below 35 so what’s that twenty point two nine let me add the RSI indicator back on here actually let me add mine back on here on the smooth RSI takes a second to load now let’s it was this one and the value was twenty point two nine so that’s exactly what we would have expected based on our point system so you can see now the entire concept of this is you can apply points in a weighted value based on where the indicators you’re wanting to use are and in order to do that you can combine multiple indicators and we just used really the RSI and the SMA here the SMA was just a trend but the RSI we actually used to indeed weight it so in the next video I’m going to add another indicator on it and let’s see we’re going to yes we are going to add another indicator on it and I think that is about it’s because we’re going to cover an indicator that we haven’t done so we’re gonna add one more indicator in here and then we are going to take a look at a different condition that we can use to add more points so for example with the RSI we covered you know if it’s in a positive trend but there’s different things you can do with a simple moving average other than just look at whether it’s going up or down I’ll take a look at something like that and then in the last video I believe there’s just gonna be three videos for the scoring development and the last video we’re gonna take a look at loops in pine script and we’re actually going to try and find those periods where there could be that divergence with the RSI and to help score our system a little bit better now it’s not gonna be perfect I don’t think anything is gonna be perfect but we’re going to be able to apply more points further in as the price goes down and I’ll show you exactly how we do that in those videos but I appreciate you watching the source code for this is going to be posted on my trading view profile on the scripts you can see that my profile is set to the username big bits IO there’s a link to it in the description we are going to be posting that script here eventually I want to finish it complete it I want to get the inputs down really nicely so you have a lot of great options you can actually come up with your own settings for it and find the most optimal one for you but for now I think that does it for the video if you liked the video please leave a like if you like these types of videos please subscribe that really helps me a lot and of course have a nice day thank you [Music]