Lépjen offline állapotba az Player FM alkalmazással!
MQL5 Tutorial – Simple Chart Objects
Manage episode 385342065 series 1376757
- Introduction to Creating Simple Chart Objects in MQL5 (00:00 – 00:34)
- Introduction to the tutorial on creating simple objects like arrows on the chart each time a tick comes in, using MQL5.
- Opening MetaEditor and Creating a New File (00:34 – 01:05)
- Instructions on opening MetaEditor, creating a new Expert Advisor file named “Simple Chart Objects”.
- Setting Up the Code Structure and Creating Price Array (01:05 – 01:39)
- Deleting unnecessary code and creating an array for price information using MQL rates.
- Sorting the Array and Filling with Price Data (01:39 – 01:52)
- Sorting the array downwards and filling it with price information for the current chart and period.
- Creating a Static Counter and Drawing Arrows (01:52 – 02:25)
- Creating a static counter and using it to draw arrows on the chart with ‘ObjectCreate’.
- Configuring the Arrow’s Appearance and Position (02:25 – 03:08)
- Setting the arrow’s type, color, and width, and positioning it at the highest point of the current candle.
- Changing Arrow Appearance with Counter Value (03:08 – 03:42)
- Changing the arrow’s appearance based on the value of the static counter.
- Setting Arrow Color and Size (03:42 – 04:23)
- Configuring the arrow’s color to green and increasing its size.
- Moving the Arrow and Displaying Counter Value (04:23 – 04:57)
- Moving the arrow to the highest price of the current candle and displaying the counter value on the chart.
- Incrementing the Counter for New Symbols (04:57 – 05:17)
- Increasing the counter by one for each new tick, resulting in different symbols on the chart.
- Compiling the Code and Testing in MetaTrader (05:17 – 05:51)
- Compiling the code and testing the Expert Advisor in MetaTrader using the Strategy Tester.
- Observing Dynamic Symbols on the Chart (05:51 – 06:11)
- Watching the changing symbols on the chart during the test and understanding how to print dynamic symbols using MQL5.
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.
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 MQL5 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 MetaEditor window and here you want to select File, New, Expert Advisor from Template, Continue.
I will call it SimpleChartObjects 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 MQLrates and it will have the name Price Information, now we are going to sort the array downwards from the current candle by using arraysetasseries and by using copyrates 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 MyArrow. Please remember in MQL 5 an arrow can look like a circle or a square or anything else.
So we use ObjectCreate for the current chart and our object will have the name MyArrow 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.
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 color 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 color green.
If you press F1 on your keyboard you will see a lot of other colors that you can use. To make our object a little bit bigger we’re using object set integer for the current chart for the object with the name MyArrow and we use the OBJProp_Width to set the size to 20.
And now we move the object by using ObjectMove for the current symbol and for the object with the name MyArrow 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 has 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 MetaTrader. And in MetaTrader 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 SimpleChartObjects.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 changing 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 MQL5 code.
The post MQL5 Tutorial – Simple Chart Objects appeared first on MQL5 Tutorial.
27 epizódok
Manage episode 385342065 series 1376757
- Introduction to Creating Simple Chart Objects in MQL5 (00:00 – 00:34)
- Introduction to the tutorial on creating simple objects like arrows on the chart each time a tick comes in, using MQL5.
- Opening MetaEditor and Creating a New File (00:34 – 01:05)
- Instructions on opening MetaEditor, creating a new Expert Advisor file named “Simple Chart Objects”.
- Setting Up the Code Structure and Creating Price Array (01:05 – 01:39)
- Deleting unnecessary code and creating an array for price information using MQL rates.
- Sorting the Array and Filling with Price Data (01:39 – 01:52)
- Sorting the array downwards and filling it with price information for the current chart and period.
- Creating a Static Counter and Drawing Arrows (01:52 – 02:25)
- Creating a static counter and using it to draw arrows on the chart with ‘ObjectCreate’.
- Configuring the Arrow’s Appearance and Position (02:25 – 03:08)
- Setting the arrow’s type, color, and width, and positioning it at the highest point of the current candle.
- Changing Arrow Appearance with Counter Value (03:08 – 03:42)
- Changing the arrow’s appearance based on the value of the static counter.
- Setting Arrow Color and Size (03:42 – 04:23)
- Configuring the arrow’s color to green and increasing its size.
- Moving the Arrow and Displaying Counter Value (04:23 – 04:57)
- Moving the arrow to the highest price of the current candle and displaying the counter value on the chart.
- Incrementing the Counter for New Symbols (04:57 – 05:17)
- Increasing the counter by one for each new tick, resulting in different symbols on the chart.
- Compiling the Code and Testing in MetaTrader (05:17 – 05:51)
- Compiling the code and testing the Expert Advisor in MetaTrader using the Strategy Tester.
- Observing Dynamic Symbols on the Chart (05:51 – 06:11)
- Watching the changing symbols on the chart during the test and understanding how to print dynamic symbols using MQL5.
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.
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 MQL5 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 MetaEditor window and here you want to select File, New, Expert Advisor from Template, Continue.
I will call it SimpleChartObjects 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 MQLrates and it will have the name Price Information, now we are going to sort the array downwards from the current candle by using arraysetasseries and by using copyrates 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 MyArrow. Please remember in MQL 5 an arrow can look like a circle or a square or anything else.
So we use ObjectCreate for the current chart and our object will have the name MyArrow 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.
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 color 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 color green.
If you press F1 on your keyboard you will see a lot of other colors that you can use. To make our object a little bit bigger we’re using object set integer for the current chart for the object with the name MyArrow and we use the OBJProp_Width to set the size to 20.
And now we move the object by using ObjectMove for the current symbol and for the object with the name MyArrow 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 has 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 MetaTrader. And in MetaTrader 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 SimpleChartObjects.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 changing 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 MQL5 code.
The post MQL5 Tutorial – Simple Chart Objects appeared first on MQL5 Tutorial.
27 epizódok
Minden epizód
×Üdvözlünk a Player FM-nél!
A Player FM lejátszó az internetet böngészi a kiváló minőségű podcastok után, hogy ön élvezhesse azokat. Ez a legjobb podcast-alkalmazás, Androidon, iPhone-on és a weben is működik. Jelentkezzen be az feliratkozások szinkronizálásához az eszközök között.