MQL5 TUTORIAL BASICS – 95 SIMPLE LOW GANN FAN OBJECT

video

 

in this video we are going to create this kind of object this is a low gann fan object and we want to find out ho w to create one with mql5.

 

to do that please click on the little button here or press f4 on your keyboard, now you should see the meta editor window and here you want to click on file, new file, expert advisor from template, continue. i will call this object simple lowgann fan.

 

click on continue, continue and finish.

 

now you can delete everything above the ontick function and the two comment lines here.

 

the first thing we need to do is to calculate the number of candles on the chart, that can be done by using chart get integer for the chart id 0.

 

we use chart first visible bar, all in capital letters and the last parameter is for the sub window, subwindow 0 is the one with the candles.

 

now let’s create a variable for the lowest candle, we also need to create an array.

 

i have called it low.

 

with array set as series we are going to sort our low array from the current candle downwards and now we can use a function called copy low that will give us the minimal bar prices for the current symbol on the chart and the currently selected period.

 

we start with candle 0 for all the candles on the chart and copy the values into our low array.

 

now we can calculate the lowest candle by using this function that is called array minimum that will give us the lowest element in our array and that’s inside of the low array.

 

we start with the first candle that’s candle 0 and we will go through all the candles on the chart and store the number for the lowest candle in this variable here.

 

let’s continue with mql rates, that will create a price information array for our prices but mql rates also will give us the time point for the candle.

 

let’s use array set as series for this one to also sort it from the current candle downwards and now we can use copyrates for the current symbol on the chart and the currently selected period on that chart.

 

we start with candle 0 for all the candles on the chart and store the candle values in our price information array.

 

before we can create a new object we want to use object delete to delete old objects for the current symbol.

 

i want to delete the objects that are called simple lowgann fan and afterwards we are going to use object create to create a new one.

 

so let’s go through the parameters here.

 

the first parameter 0 stands for the current chart.

 

the second one is the object name.

 

i have called my object simple lowgann fan.

 

parameter 3 is for the object type, i’m going to use obg underscore gannfan here.

 

if you mark that and press f1, you will see that there are lots of different objects.

 

this is the one that we are going to use.

 

the next parameter is for the main window, that’s windows 0 and we want to draw our object for the point in time where we have the lowest candle in our price information array.

 

we want to start with the lowest price of the lowest candle.

 

the second reference point is the point in time for the current candle 0 and as the last parameter we are going to pass the low price for the current candle in our price information array.

 

that’s it for the object create part.

 

let’s set a few properties.

 

the first property is for the object color.

 

we are using object set integer for the chart id 0 and the object with the name simple lowgann fan.

 

we want to change the object property color and set it to red.

 

now let’s set the trend direction.

 

the first part is similar but this time we are going to use object property direction and we are going to use gann uptrend.

 

let’s continue and set the scale.

 

that is done by using object property scale and my value here is 2.

 

and finally we want to set the property object property rayright to true because that will give us a kind of object prediction and draw the lines right into the future.

 

so far so good.

 

if you have no idea what all the code here does or if this was too fast for you, maybe you want to watch one of the other videos in the basic video series.

 

or maybe even the premium course on our website might be interesting for you.

 

for now please click on view toolbar and click the little button here or press f7 on your keyboard.

 

i need to remove this bracket here.

 

now recompile the code and this time i don’t have any errors and if this 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 ctrl and r.

 

please pick the new file simple lowgonfan.ex5 mark the option for the visual mode here and start your test.

 

here we are our little expert advisor is working as expected we see that the gann fan object is drawn from the lowest candle on the chart and in this little video you have learned how to create a lowgann fan object on your chart.

 

and you have coded it yourself with a few lines of mql5 code.