MQL4 TUTORIAL BASICS – 96 SIMPLE MOVING TEXT OBJECT

video

 

In this video, we are going to create such a moving text label, this one is for the low price. It is moving as the low price for the current candle changes. So let’s find out how to do that with MQL4. To get started, please click on a little icon here press F4 on your keyboard now.

 

You should see the Metaeditor window and here you want to click on file. New file Expert Advisor from Template continue. I will call this file simple moving text. Click on continue. Continue and finish. Now you can remove everything above the ontick function and let’s also get rid of the two comment lines here, we start with object create that will create an object called moving text. This is the object name and this is the object type. There are two ways to do that.

 

If you click here, you can see that the number of parameters are changing. So let’s mark that and press F1. And now we see that we need to pass a few more parameters after the object type. We need to tell Metatrader the window in which we want the object to be created. And two more variables for the time and the price. I have set all three parameters to zero. Window zero is the main window with the candles and for the time and the price we are going to use object move.

 

Now we can use object set text for our moving text object. We want to see the text low price followed by a colon, and afterwards we want the value for the low price for candle zero. The font size will be eight. We are going to use this font type and it should be a red text. I would like to have a vertical text output. So no, I’m going to change a property that is done by using ObjectSetDouble.

 

The first parameter is for the current window. We want to change the property for the object called moving text. The property I want to change is object property angle and I set it to ninety degrees. Afterwards we are going to move the object, that is done by using object move for the object called moving text.

 

This is the anchor point of the object. Basically it’s for the alignment and we want to move the object to the point in time for the current candle zero to the low price of candle zero and that’s about it. Not much code. But if it was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in our basic video series. Or maybe even the Premium Course on our website might be interesting for you, for now, please click on Compile or Press F7.

 

You shouldn’t get any errors here, and if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader you want to click on View Strategy Tester or press Control and R. Please pick the new file Simple moving text dot .ex4, mark the option for the visual mode here and start a test. Here we are, our object is drawn on the chart. Actually, this was a question from a Premium Course member, and if you would like to become a Premium Course member or if you would like to download other source codes for MQL4, you can do that on our website, because now you know how to create a moving price object in MQL4. And you have coded it yourself with a few lines of code in Metaeditor.