MQL5 TUTORIAL – PLATIN SYSTEM ACCUMULATION DISTRIBUTION OSCILLATOR

video
play-sharp-fill

 

In this video, we are going to create an entry signal file for this oscillator here. It is called accumulation distribution. Usually, oscillators are used to confirm signals, but in this case, we are using it as an entry signal. And as you can see, it is actually working.

 

The Accumulation Distribution oscillator is drawn on a separate chart below the candle chart.

 

It has a single signal line which will show a value.

 

To use it, we create a separate MQ5 file inside of the directory where the other files of the Platin System are located.

 

The name of the file is CheckEntry_IAD.mq5 and it contains a single function that is called CheckEntry.

 

This function calculates the buy and sell signals for our system.

 

Actually oscillators are not meant to generate signals, they are rather used as filters for other indicators.

 

But that doesn’t mean that we can’t use them, because all we need for our trading system is a working signal that is well defined.

 

We start by creating a string variable for the signal.

 

That will later be returned to our main function, but before we do that, we need to create the signal first.

 

We also need to create an array for price data.

 

And with ArraySetAsSeries we sort our array from the current candle downwards.

 

Afterwards we can create our definition for the oscillator by using the iAD function that is already included in MQL5.

 

The first parameter is for the current symbol on our chart and the second parameter is used for the currently selected period on that chart.

 

The third parameter can be used to select the applied volume. We will use Volume_Tick here.

 

Now let’s use CopyBuffer to fill our array with data.

 

The first parameter here is the definition that we have created above. Parameter 2 is for the buffer that we want to calculate. 

 

This oscillator has only one buffer, so we set it to 0.

 

The next parameter is for the candle where we want to start. 

 

We pick the current candle 0 and in the next parameter we define the number of candles that we want to calculate. 

 

In our case we do it for 3 candles.

 

The last parameter is for the target array, that is our price array.

 

Now we are able to calculate the values for the current candle and the candle before.

 

To get the current value, we look at the value for candle 0 in our price array.

 

To get the value for the candle before, we do the same for candle 1.

 

Now we are actually able to calculate our signal.

 

If the value for the current candle is higher than the value for candle 1, we assume that this is a buy signal.

 

Therefore we assign the word buy to our signal.

 

Otherwise, when the current value for candle 0 is below the value for candle 1, we assume this is a sell signal.

 

Then we will assign the word sell to our signal.

 

And finally we use the return statement to return our calculated signal to the main module.

 

Please do not forget to save your entry file, but you don’t need to compile it right now.

 

The compilation is done in the main module, but before you do that, please find the include statement for the entry signal and modify it to use our new file named CheckEntry_IAD.mq5.

 

You can outcomment other entry modules by adding two slashes at the beginning of the line.

 

Once you have done that, you can press F7 or click on the compile button to compile your main module and the included entry signal file.

 

You shouldn’t get any errors.

 

If you do, you should consider buying the Premium course or watch one of the starter videos to understand the process.

 

Okay. If all went well, you should now have a working version of the accumulation distribution oscillator on your chart. So that’s it for this oscillator video, and I will see and the next one. Thank you for watching.