 Welcome back to the ThinkScript series. We're going to jump over to the study range. So I want to introduce or combine some of these concepts that we have been talking about. So let me see here. Let's start by just looking at what we have defined up here. So we define five variables that are input type. So again, these are modifiable by the user. And we're basically taking the high, and there's no brackets here, so it's not yesterday. It's not any other particular day in the past. It is today's high and the day's close. And we're assigning it to these variables here, the range high price and the range is low price. We're just creating a simple average type, in this case, for our moving average, which we will use later. And then we'll create the length for the moving average, which in this case is going to be the 10-day moving average if we're doing it daily. And then we'll mess around with some offsets there if we want to later. But for now, we'll just set it to zero. OK, so what are we doing? Well, what we're doing is we're taking the absolute value. And again, if you ever want more information on these, you can just click on this. And this gives you a brief description of it. If you want more details, you can actually click on that as well. But basically what we're doing is we're taking the high and subtracting the low from it. So what we're getting is the range for the price levels that this stock has been trading in for this trading day. So we're creating that absolute value and assigning it to the variable rg. And similarly, we are taking the simple moving average of this data. It's not the price moving average. This is the range is moving average, which we calculated up here. And we are using the 10-period moving average, simple moving average, of this data set called range, or rg. And like I said, we're not using the offset right now, but we can leave that in for future use. And we're assigning that to an immutable variable, in this case, which is AVG. So both of these are defined. These are modifiable. And then what we're doing is we're plotting both of those. So we're taking those and we're simply plotting them. We're basically using a more human-friendly word, average and range. I was just doing that to show around how to reassign stuff. OK, so we've created this, and we've plotted it. So let's go ahead and go to the chart. Now if you move it over to the lower, then it gives it its own, let's apply, section down here below the chart, which is way more readable. So let's go back to our code and look at this. Because we have gone through this section so far. And now let's go ahead and look at some of these, which are basically not new stuff in the sense that it helps us calculate new data. It's just a different way to format stuff. OK, so what are we doing here? We're introducing something called Painting Strategy. So a particular range, you can set it to a certain painting strategy. And that painting strategy is going to be the squared histogram. And if you want to know more about that, then come in here again and go Info. And then it'll tell you that it controls the painting style of a particular line. So we're using the squared histogram painting strategy for this range that we have obviously defined up here. And next, we set the default color for the average, which is the second one. We define the range and the average. We assign them a value. And now we're basically changing the way they look. We're setting a painting strategy on this one. We're setting a default color on this one. And then we're actually changing the default color. So there's different ways, basically, to show you of how to change, we're going to type this in here, different ways to change coloring or formatting. So for example, for default color, you can set it by saying color.orange or color.black, if you want, which is a lot more human friendly. And you can just select that. I'm not going to do that right now. So I'm going to set this back to orange. And then if you are a little bit more versed in color coding, then you can actually create an RGB color, which is create color with what that is. And again, you can go and look at the info here. And it'll tell you that it is based on an RGB color, where RGB is red, green, blue. So it assigns a different value to each one of those RGB individually. And we set a color for the range. And then we can actually also define colors by using, in this case, we're using define the color high and define the color low as high being blue and low being red. So what we're going to get into now is this section down here, these bars and this line. So the line, if you recall, is the average. The bar, if you recall, is the actual range. So this is representing the value of the line today. And the range is representing this value right here, which is the bar. Now let's go over to our code again and look at what we're doing. We're going to change the colors based on the value. So range, for example, we will assign a value of color if the range is greater than the average. So let's just see what that means. If the range, which is this bar, is greater than the average, which is the line, so if the bar is greater than the line, then we want to assign the cyan color, which is the teal I was talking about. Else, or otherwise, we leave the range red. So what that means is if this bar is greater than the line, it's cyan color, the bar. If the bar is less than the line, then the bar stays red. That is what we're doing right here. So we're formatting based on values. So that was that first line right here, the range line. Now let's look at the average, which is the line. These are the bars, the range bars, and this is the line, the average. We're also going to assign value color. And we're going to say if the average is greater than the previous day's average, so if whatever average today is greater than the average yesterday, which means that it is upticking, then we want color uptick. Makes sense, right? Else, we'll use the color down tick. And these are colors, down tick, and these are actually base colors. So it's telling you what that base color is. It is the base or default color that Thinkorswim uses whenever there's a down tick, in the case of a down tick, or the up tick. So the down tick is 204 red, makes sense. There's a lot of red. These go, I believe, up to 255. So 204 out of 255 is pretty much as much red as you can throw in there. Zero green and zero blue. If you start mixing in blue, for example, you start increasing this, and then this is going to look more purplish. And if you throw in some green, that's going to make whatever purple and green make, which I'm not sure what it does. But in this case, it should be pretty straightforward. There's 204 out of 255 possible red value assigned, which makes it intensely red, and no green or blue. That's down tick. If we look at up tick, which means green, if you think about it, R and B should be zero. And G, the middle value, should be 204 or 55. Well, I don't know what happened here, but basically, three red and zero blue out of 255, that's pretty much negligible. And then 128, which is about half of what the green component of this RGB color would be. So that makes sense, all right? So we're changing the bar's color, depending on if it is below or above the average line. And we're changing the average line itself to either red or green, depending on whether it's greater or lower than the previous day. So let's see how that works out. Now, this, as you can clearly see, is today's is lower than the yesterday's, and therefore, that segment of the line is red. So you can see the downtrends here all marked in red. And you can see the uptrends, which not that many, but some of them here, in green, OK? So three days in a row, it was bigger, right? That moving average was larger, and therefore, you have a green colored line, all right? So in the end here, what we're going to do is we're going to say, OK, we're going to want to create a threshold, right? Which is alert range multiple is two. If it's twice as big, then we want to be alerted, right? So we create an alert. We can create alert and code just as well as we can by using the GUI right click over there on the show you a long time ago by right clicking on tickers and whatnot on charts. You can also create alerts and code. So what is this alert going to be? Well, basically, when the range is greater than or equal to the average, the average multiplied by that range multiple, which in this case is two. So what we're saying is if the range is twice the average, then high range bar, OK? Comma alert bar comma sound ding. So what we're saying here, if we come over here and inspect using the info, OK? So it is showing an alert message with the text and it plays a sound as well. What sound? Well, in this case, it's playing the sound ding. Now, if you don't get enough information when you come down here, like I said to the info, then you want to go over here to more details and here we are alert, right? So there's the string sound. The condition is where we define if the range is greater than twice the amount of the average, OK? Then display this text of the alert message. Alert only once in case you only wanted alert once and use the particular sound, right? And then it gives you an example and you can even go in and check out the different sound options if you so wished. Aside from the ding, there's the bell, there's the ring, there's the chimes, et cetera, et cetera. So that is what we're doing here. We're creating the alert and Thinkorswim will basically throw up an alert message with the words high range bar and sound the ding message whenever the day's range is greater than twice the average. Now let's see if that happened any time in the past. The range would have to be the bar twice. It might have happened here, right? It might have happened here where it was 7.33 and the average was 3.4, 3.5. So actually 7 would have been twice the average. So it would have dinged here in that particular day, right? It didn't happen today, obviously, because it's not twice as large. So once we do that, we throw up some labels, right? The high label and the low label. One of them is white. One of them is orange. And we're going to add the label here. The label is invisible immediately and it is composed of text such as range. And we are appending the range RG as dollars so that it gives us the nice dollar sign. Otherwise, if we do as text, it'll just throw up 3.32. And then we're adding to that text the pipe symbol and then the average, which is the average value that we calculated above as dollars as well. And if the range is greater than the average, then it'll set that label to whatever high label color it was, which is white, right? Else, the global color will be low label, which is defined up here as orange. So this means that range must be below the average, which is true here. The range is 3.32, which we can clearly see on the label, 3.32, and the average is 3.48. So because the average is greater than the range, then this is an orange, which to me actually looks yellowish in color, yellow colored label. OK, so I hope you guys enjoyed this video. And if you have any questions on what we covered today or anything else, don't forget to leave a comment. Also, don't forget to like the video and subscribe to our channel. And if you use the invite link that is posted in this description to get your Xtrades membership plan, then I will give you a free personal video guided tour of the Xtrades Discord community, as well as the web application for Xtrades. And I will tell you or guide you through how to take alert signals and I'll even throw in all of my educational materials, such as videos and presentations for your benefit. So I hope you enjoyed the video and I'll see you next time. Have a great one. There's a reason why Xtrades is currently the fastest growing application on the market for sharing financial ideas. With over $2.5 million paid in the last two years as the contributors, users are flocking to see what trades the top traders on the leaderboard are sharing in real time. If you're looking to grow your reputation as a trader on the internet or discuss your trading ideas with other reputable investors, click the link below and get connected with a trading mentor today, completely free of charge.