00:00Hello and welcome to tutorial 216. In this tutorial I had a question as to how to create
00:08a show me study that showed the volume of the current bar in the right hand box,
00:15the bar before that and the next box and so on for the next five bars and as you can see the
00:21the up-to-date the the most recent bar is updating as as the bar develops. So let's have a look at
00:28the program and first thing we need to do is when the program is first applied to the chart in a one
00:36statement we're going to be creating a charting host and we're going to be creating two events
00:43for the charting host. One is initial update on initial update and the other one is on size. So
00:49in other words if we go back to the chart and we decide for example drag the chart you'll see that
00:56the the size of the the boxes adjust. Now if you if you're unfamiliar with how to set up the charting
01:04host what you can do is go to toolbox double click on the charting host and in fact let's just do that
01:11and then having selected that if you go to this events icon here and then you can click double
01:18click on the events that you want an event to take place. So we've done on initial update and we've
01:25also done one on size so by clicking those you'll see the syntax but we don't need to do that right
01:32now it's just going to delete that and we've also created a couple of vectors one text effect and one
01:39box effect these these we're going to use to store the the text objects and the the rectangle objects
01:47as we create them then the next thing we do is create the initial text objects and rectangles
01:56now we don't have any specific place to put these we just put them in a random place but what we have
02:04done is set some of the attributes of the item so for example text object we needed to make it persist
02:13we've used we're setting the font and we're using actually a user input for the font name font size
02:19color again it's a user input and we've set the h style v style and then we've added that to the chart
02:26we're doing this for zero one two three and four four so five text objects and at the same time
02:35we're also drawing a rectangle now we're using the the method draw rectangle which i've created and
02:42again we're just putting these in a random place we're also setting the color so the color depends
02:47whether the counter value is zero one two three or four then we're adding that to the chart so this
02:54means that once those have been created even if we change the size of the chart we we will not need
03:00to recreate those so the next thing is well let's just have a quick look at the the rect or rectangle
03:08method which just makes things a little simpler and it's just using the the rectangle dot create
03:16and in this case you'll notice that we're using x y points and the advantage of the x y point
03:22is that even as we get more bars and so on the position of the x y point doesn't change so that
03:31will stay static in one place on the chart anyway this is the method to draw that and to add it to
03:40the chart and to return that value which we then store in the vector what we then got are the two
03:47the two events both similar or in fact exactly the same syntax and what we do is every time one of
03:55these events fired one of the events is fired we go through the counter 0 1 2 3 4 4 and what we do
04:04is we change the for example the position of the text we calculate where it's supposed to be at the
04:14current time and that depends on the width of the window we know that through args dot width
04:21and by calculating where we want it to be you can position it so that you've got those five
04:29different positions for the text and then so we're creating the x y point using this calculation
04:40based on args dot width which is the current width of the window then we're setting the point value of
04:46the text label to that value and then we're doing something similar with the rectangle but we're doing
04:51set start point and set end point and again we're calculating the x y point in this case we're doing it
04:58within the uh within the input to the set start point and those values ensure that we get the five
05:05different rectangles um equally spaced and uh they've already been given the color that we needed
05:13incidentally the colors are set to be user inputs so color one two three four and five um using the color
05:23objects you can see that they're in quotes the text color we can also set the color i've set that to
05:29ivory font name in this case um arial font size and then height percentage now what this does is works
05:39at how thick the lines are going to be so for example if you had a far smaller chart you might wish to
05:45reduce that value um play around with that to make sure that the the rectangles are the size that you
05:53want uh we've got namespaces as you can see which i've uh included some comments as to what they do
06:01and then the final thing we've got is that we're updating the volume values on each tick so the uh the
06:10volume value we get from the ticks keyword and bear in mind ticks the word uh the keyword ticks
06:16varies in its meaning uh depending on what sort of chart and what the the setting is in uh for the
06:23show me study so you might want to just read up on that if you right click on ticks um say definition
06:29and then go here click on easy language reserve words related ticks volume etc and then you can see
06:37what the various different meanings are so ticks is total volume for uh for charting stock stock symbols
06:44intraday however if you set the uh the tick count uh if the uh that's only if trade volume is selected
06:52if tick count is selected then it becomes the total number of ticks so the up-to-date value of um of
06:59volume is is calculated each time and then the the text string is set to that value or rather the uh the
07:08number is converted to a string and then the text string is set to that value and you can see uh if
07:14you look at the chart that being updated as the the bar develops anyway hopefully you might find this
07:23useful if uh if you want to type it in you're very welcome to do that otherwise i will make it
07:30available on markplex.com and as always also please consider joining gold pass thank you very much
07:41thank you very much
07:56you
Comments