NearTerm Line Peak/Trough Study

nearterm This is a topic that many people are looking for. is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, would like to introduce to you NearTerm Line Peak/Trough Study . Following along are instructions in the video below:

“Evening think scripts colors i m clarence carr and tonight we re going to do do an additional video about the use of think script and i thought it might helpful to learn how to reference other studies and use them in your study and the study. I ve chosen to reference is the market forecast and we re going to do a study that looks at the prices associated with the peak and trough of the near term line on this study. A lot of people feel like these are valid. Support and resistance areas.

So that s why we re going to do this study and i think it will be instructive in the meantime. So here i have my chart of the spy setup and at the bottom. I have my version of the market forecast. I like to put the dots in the blue line.

So i can count to see whether it s been seven to twelve days above the 50th percentile as you know david often says that it needs to stay up there for that period and of course. I m talking about david settle at market scholars comm. So what we re going to do is set up this study and i ve got this study written separately and i m we re just going to copy sections of it over as we talk about it we re gonna clean this up to start with here as always this brings up this new study by default and counts depending on how many you haven t cleaned up. I ve got a few out there apparently i haven t cleaned up so.

We did talk a little bit in the last video about how i like to do a header and i m gonna spend a little bit more time on that today so i m gonna bring my header in here. And this is a little bit more how i often have my headers. You ll notice that i also have a little bit of a complex name in here. I have found that when i m writing a lot of code.

I have various revisions and they re they re all named the same thing. It s very difficult to keep track of what changes. I ve made where so i tend to put in first of all my initials and then i underscore followed by the year month. And day that i actually wrote the study and then i will have another underscore and actually name the study.

I ve also found that sometimes i really want to know what the study is when i m looking at the chart. So i can go oh. That s not my latest version and because of that i will have these two lines so input name you have to do text. If you re going to have text like this you have to put it in an input statement even though you really don t want to change it later on but it s the only way you can really input a text string like this unless you hard coded into the label.

Which would be another option here we could just take this piece of code right here or that little text. I should say and we could just copy it down here..

Where it says name and you would have the same effect. So that s certainly another way you can do this i ve been have the input statement for show label and i use this true or false value here to decide whether i want to show the label or not because of course. Sometimes i may not want to we re gonna keep it at yes right now just for fun. So i can demonstrate this really.

Then i have this little disclaimer. I like to put in just in case somebody else is using my software and decides they don t like it or there was a mistake in it or something along that line and i m going to bring over the next statement is to declare where we want this to show up and we want this study to show up on the upper price graph not on one of the lower subsections or windows. Now the other thing. I m going to do which is completely optional is just just for demonstration purposes.

I m going to put in a red green blue numbers as input statements so that you can you know or the user could change. These later this will be basically just to reference some of the colors in our study and as you probably know rgb you have the three variables or parameters that you pass to the color statement and this will set your color based on numbers from zero to emily. That s 255 with all zeros being black and all being 255 is a white color. So going to next define a global color which will involve or reference these numbers.

I have to just give me one second here i have to just do a slight edit off screen here. So i can do this right there we go so well what we re going to do is have a global color that we re going to call study color and we re going to create that color based on these values that are put in here. Now we re going to reference another study. The study that we want to reference is the market forecast study and we re particularly interested in the near term plot of that so how that is done is with this line right.

Here plot your term equals. Reference market forecast. You have to include the parentheses. Period and then which of the plots within that study you want to reference.

I should note that this is completely optional to put the reference term in there you can delete that and have exactly the same result. Now we don t really want to show the near term line on this study. So we re going to place say near term period hide parentheses. The reason you have to do this is you can t just make this a definition.

When you re referencing. Another study..

So you have to do that as a plot. But then you can hide that plot so it doesn t actually show now what we want to do with the near term line first of all is to find the peak and we re going to define the peak in this manner define p. If the near term line is greater than 20. And the near term line currently is greater than the near term line value one candle ago remember in these studies.

When think script executes. It always starts at the left side of the chart and moves across to the right side of the chart and this indexing that we talked about a little bit is a method to see what the prior candle or bars value was for comparison or for setting your current value. Now. The reason.

I ve included the near term greater than 20 is that in general when i ve heard this talked about in the past. And i will say that blake young who was previously at investools had talked about this a fair amount. And he certainly he always preferred to have the near term line out of the reversal zones. When he was using it for support and resistance so i ve set this to be greater than 20.

I ve said that the near term line has to be greater than the prior near term and the near term has to be greater than the next so what we re finding here is the peak. So you can understand that the prior bar. Let s say would be here this bar would be here and the next bar would be down here again so that that s what this logic here tells us and then we take the clothes at that peak. And see what the closing price is or else.

It s a null value double knot a double na n. Which is means not a number so now the next step is to be able to carry this forward so that we know after the peak occurs when the last peak was so we re going to find and hold the last valid peak price data so define the last peak equals to if this number was in fact a number one bar ago then carry that number forward else carry this number forward so in other words. If you ve just had a new peak in the prior candle here then you re going to use that closing price from that peak value otherwise you re going to just carry forward the value from whenever the last peak was maybe the last peak was three bars ago. But you would carry this forward each time saying okay.

It s it s it s not a new peak. But so we re not going to use this number. But we will go back and carry this number forward in a recursive fashion. Okay so now what we re going to do is we re going to plot this and we re going to format.

The plot a little bit so you cannot again you cannot plot a recursive statement. It you can define it and then plot that out later..

But you cannot plot it immediately so you cannot make this a plot statement here you have to come down. And say plot lp for last pape of course equals if last peak does not equal zero. Then the last peak minus. One else mm.

So it s looking forward now because remember this was offset up here looking forward and so to make this line up you have to make this offset one to the right else null now. We re gonna use our study color. Which can be set by the user by changing these rgb numbers. We re going to make it a horizontal painting strategy we re going to set the line weight to two we re gonna hide the title up above because we don t want a whole lot of things up in that top line and we ll talk about that when we actually look at this and then we re gonna hide the bubble over to the side so let s see how we re doing with this so far they re select.

Okay okay now you can see that there is there are lines here and have been established. I believe that s a drawn line let s take that off yeah. And you can see that these lines are all corresponding to peace soph. Right here.

You can see that there is a peak down below on the near term line. That blue line down below and each of these correspond to one of those peaks. So now we re going to have to go in and do the same thing on the trough you and i m gonna bring this over it s basically very similar to what we ve done on the peaks. But just looking a little bit differently.

We re looking at the near term being less than 80. We re making sure that the current near term value on this candle is less than the prior and less than the following a candle and if so then we get too close and we get a trough value then similar to how we did above we either set that trough value. If it s a new trough that has just occurred or if it s if there s not a trough that has just occurred. We carry forward the prior value of last trough then again we plot out the last trough.

We set up our formatting. So let s look at that so now you can see we have both of these plotted out to over time now. It s you could say well you knew those different colors. You know there are a lot of ways you could define.

Which was top and which was bottom. I know that they re all gray right now..

But what i think kind of helps us out and it s good to look at this command. Anyway is first of all we re going to fill this area you with a cloud now what this how this cloud command. Works is this you say add cloud. The first parameter is the last trough.

The second committer is the last peak. If the last trough is greater than the last peak then this color will show otherwise this color will show now we have the same color in both of these so it doesn t matter too much. But what we re trying to do is have a cloud that appears between these two values. So i m going to apply that and let s see what we have now so.

Now you can see that it sort of makes sense your eye naturally of sees this range and understands you just visually can understand where the peak and the trough are so one other thing you ll notice that this goes on past this is kind of what we want to goes over here in this area past the last candle and here what i m going to do is we re going to put bubbles that identify those levels. So come down here and this will be the last thing. We do on this chart or on this study excuse me so add chart bubble and what this says is this is for placement. This first part is for what bar do i place this on that s what everything up to this first comma is the next item is what level do i put this at then what do i put in the bubble.

The color of the bubble. And then where does this get placed up above that price or below. That price so add chart bubble. If close is not a number so you want to make sure you re not putting your bubbles over on top of your price action.

You don t want to get in the way of your price action and then you say and is nan close one. So. If the current value is not a number and the prior value was not a number but two bars ago. It was a number then you want to print these values and this logic is the same for both let s apply that and see what we have and now we have our bubble showing up here.

And that s the study. So i hope that was helpful somewhat in how to reference other studies and also we discussed the cloud command a little bit and hopefully just helps a little bit to familiarize you with how things script works thank you very much ” ..

Thank you for watching all the articles on the topic NearTerm Line Peak/Trough Study . All shares of are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.

It has been suggested by some that the Nearterm line of the Market Forecast Study points to support and resistance levels at peaks (resistance) and troughs (support). This video shows how to reference other studies and use the AddCloud Command.

Market Forecast, ThinkScript, TOS, tutorials, Support, resistance, Scholars, MFC

Leave a Comment