MQL5 TUTORIAL – PLATIN SYSTEM – VARIABLE INDEX DYNAMIC AVERAGE

video
play-sharp-fill

 

In this video we want to check out the indicator for this little red line here. It is called the variable index dynamic average. And we want to create an entry module for it. So let’s see how that can be done with MQL5.

 

This indicator is drawn on the candle chart as it produces values that can be shown inside of the price range of the candles.

 

To calculate the entry signal, we first need to create a new file inside of the directory where the other files of your system are located.

 

The name of the file is CheckEntry_IVIDYA.mq5 and we use a simple function named CheckEntry to calculate the signal for the indicator which will be returned at the end of the function.

 

But first we need to do a few things to actually calculate the signal.

 

Let’s start with the signal. Please create a variable called signal. It is of the type string, so it can hold text values.

 

Afterwards we create an Array for price data by using MqlRates.

 

And to sort that array we use Array set as series. That will sort it from candle 0 downwards.

 

So far, so good. 

 

Now we want to fill the array. That can be done by using CopyRates and we do it for the current symbol and the currently selected period for that particular symbol. 

 

We want to store prices, starting with the current candle 0, for three candles and the results will be stored in our price array.

 

Now, please create another array for our Expert Advisor.

 

This also will be sorted downwards by using Array set as series, like we have done above.

 

MQL5 has an included function that is called iVIDyA.

 

We use it with the following parameters.

 

First we pass the symbol and the period, followed by the values 9,12 and 0. 

 

If you open a Metatrader chart and click on Insert, Indicators, Trend, Variable Index Dynamic Average, you will find that those are the standard values for the CMO period, the EMA period and the shift value.

 

So let’s continue with the code here and in the last parameter we use PRICE_CLOSE, because we want the result to be calculated based on the close price.

 

Afterwards we use CopyBuffer for the definition for our Expert Advisor. 

 

We want to calculate the buffer 0, we want data from candle 0 for 3 candles and we want to store the result in our array for the Expert Advisor.

 

The rest is easy.

 

When we pick the value for candle 0 inside of our array, we can use that to compare it with the candle prices.

 

If that value is above the close price for candle 1, we want to buy.

 

If it is below the close price for candle 1, we want to sell.

 

So we assign the word buy or sell to our signal variable and use return to return the calculated signal to our main file, which is the one that contains the OnTick function.

 

Don’t forget to save the file. Compiling will be done in the main file, you just need to save it.

 

Let’s open our main file now and find the include statement section.

 

There you want to outcomment other entry signals.

 

Just add two slashes before the include statement, that will disable them.

 

Add another line to include the file we have just created and afterwards you can compile the main file and the entry signal module at once by pressing F7.

 

You can also use the compile button if your toolbar is enabled.

 

That should not produce any error messages, but if you have errors, please check your file line by line.

 

If this was too fast for you or if you have no idea what all those code lines mean, you might want to watch a few more basic videos or maybe the premium course on our website might be interesting for you.

 

Okay, if everything worked well, you should see the indicator on your chart. It is trading in my case. If you have any problems, you can contact me. And in this little video, you have seen how to create an entry signal for this indicator. I can’t even remember the name.

 

It is called variable index dynamic average. Thank you for watching and I will see you in the next video.