In this video we are going to create the Bollinger bands indicator for the Platin System. But you can also use this entry signal for your own system or for the robot trading system. The Bollinger Bands actually is one of my favorite indicators and it was the first one that I used to create a profitable system. So let’s find out how to do that with MQL5.

The Bollinger Bands indicator is drawn on the candle chart.

It has an upper band, a middle band and a lower band.

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_BollingerBands.mq5 and it contains a single function that is called CheckEntry.

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



We start with MQLRates to create an array called Priceinfo.

Afterwards we use ArraySetAsSeries to sort our PriceArray from the current candle downwards.

And then we use CopyRates to fill our PriceInfo array with data.

The first parameter is for the current symbol on the chart.

The second parameter is for the currently selected period on that chart.

Parameter 3 is used to define from which candle we want to start.

Parameter 4 is for the number of candles that we want.

And the last parameter is the target array where we want to store the prices.



Now we will create a string variable for the signal, but we don’t assign a value.

The next step is to create three arrays, one for each of the Bollinger Bands.

Of course, we need to sort those also from the current candle downwards by using ArraySetAsSeries.

MQL5 comes with a builtin function that is called iBands and we use it to create a definition for the Bollinger Bands.



The first parameter is for the current symbol on the chart, the second one for the period on the chart.

The third one is for the number of candles we want to calculate. In our case 20 candles.

Parameter 4 is a shift value. We don’t need that, so we set it to 0.

Parameter 5 is for the deviation. We set it to 2, because that is the default value.

And in the last parameter we can define that we want to do the calculation based on the close prices.



Let’s use CopyBuffer again to fill our three arrays with data for the middle, the upper and the lower band.

We do it according to the definition that we have created before for buffer 0, buffer 1 and buffer 2, starting from the current candle 0, for 3 candles.

That makes it possible to calculate the values for each band by looking at the candles 0 and 1.

If the close price for candle 1 was below the lower band and if the current close price is above the lower band we consider that to be a buy signal, so we assign the word buy to our signal.

In the other case, if the close price for candle 1 was above the upper Bollinger Band and is now below the band we would consider that to be a sell signal, so we assign the word sell to our signal.



Finally we return the signal to the main module by using the return statement.

Now, please save the file. You don’t need to compile it as it will be compiled with the main module.

Okay, by now you should have a working Bollinger Bands indicator entry module for your system. I actually like this indicator very much. So thank you for listening and I will see you in the next video.