MQL5 Tutorial - Simple Chart Objects
https://mql5tutorial.com/?s=chart
With MQL5 for Metatrader5 we create several objects on the chart. The objects will be created with the ObjectCreate() command and are so called "arrows", but they can have almost every kind of form you can imagine...
This time we are going to create simple objects. Each time a tick comes in, one of these objects will be painted here usually you will see things like arrows up and down but actually there are a lot of more possibilities for such an arrow symbol and everything you see here is called an arrow even if it doesn't look like one. Now how can we create an Expert Advisor in MQL 5 that is going to draw objects like these? To do that please click on the little button here or press the F4 key on your keyboard. And that will bring up your Meta Editor window and here you want to select File, New, Expert Advisor from Template, Continue, I will call it Simple Chart Object here, Continue, Continue and finish. And now you can delete everything above the OnTick function and the two comment lines here.
And first we need an array for prices, we can create one by using MQL rates and it will have the name Price Information, now we are going to sort the array downwards from the current candle by using array set as series and by using copy rates we are going to fill the price information array for the current chart and the period selected on the chart from the current candle zero for all the bars on the chart and store the values in our array. And now we are going to create a static counter, it will be an integer with the name i, and we will use that value to actually create an arrow with the name My Arrow. Please remember in MQL 5 an arrow can look like a circle or a square or anything else. So we use Object Create for the current chart and our object will have the name My Arrow and we use OBJ_Arrow to create it. The next parameter would be a sub window; we will use a zero here because we are going to create the arrow here in the main window. You might have seen indicators that use a sub window below and we will use the current time and the arrow should be placed on the highest point of the current candle in our price information array we have created here.
And with object set integer for the current chart, and the object, my arrow, we use OB J Prop_Arrow Code, and the value of the static counter to change how our object looks. Currently we have the value 179 and as soon as that changes to 180 the arrow code changes and so does the way our arrow looks. And for 181 our arrow would look like this; let's select a colour here, that is done by using objects set integer for the current chart for the object with the name My Arrow and we use OBJ_Prop_Color and we would like to have the colour green. If you press F1 on your keyboard you will see a lot of other colours that you can use. To make our object a little bit bigger we're using objects set integer for the current chart for the object with the name My Arrow and we use the OBJ Prop_Width to set the size to 20. And now we move the object by using Object Move for the current symbol and for the object with the name My Arrow on the main window we used for the current time and we move it to the highest prize of the current candle. I would actually like to have a chart output for the current counter value so we use comment to output the text I add the value followed by the current value of the static integer variable I. And in the last step we are going to increase our counter by one, that is done with I++ and now the next time a tick comes in we should see another symbol on the chart.
Okay that's it; let’s compile the code here and that worked without any errors. So please click on the little button here or press F4 on your keyboard to go back to Meta Trader. And in Meta Trader click on View Strategy Tester or press control and R to bring up the Strategy Tester Panel here and there you want to select the file Simple Chart Objects.ex5. Let's start the test after you have enabled the visualisation option here and for the first 20 counter values nothing changes, but around 30 you will see change in symbols on your chart and now you actually know how to print dynamic symbols on your chart and you have done it within a few minutes by using a few lines of MQL 5 code.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «MQL5 Tutorial - Simple Chart Objects», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.