MQL4 TUTORIAL BASICS – 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR

video
play-sharp-fill

In this video we are going to create an expert advisor that is able to use the Bollinger Bands to create a Buy or a Sell signal.

And we are going to use the MACD as a filter.

So let’s find out how to do that with MQL4.

To get started, please click on the little icon here or Press F4 on your keyboard. Now you should see the Metaeditor window and here we have the precoded solution. In my case, I’m doing an include function for the Bollinger Bands module and for the MACD module. Both are separate files and the include function can import the content of those files. And they will be compiled when you compile the main module, which is the one with the Ontick function.

And here we create a string variable for the trading signal and another string variable for the filter. And to get the trading signal we are opening a function that is called CheckEntry Bollinger. And to create a filter signal we open a function that is called Check Entry MACD.

And when we have a Buy signal and the filter for the MACD also says that we should buy and if the return value for Orders total equals zero, that would mean all conditions are good for a Buy signal.

And that’s when we use Order Send to open a Buy Trade for ten microlot.

Otherwise, when the trading signal equals Sell and when the filter also equals Sell and we have no open positions, that’s when we use Order Send to open a Sell Trade for ten microlot.

Finally, we use the comment statement to output the trading signal and the filter signal on our chart. That’s it for the main module.

For the entry signal and the filter signal we use precoded entry modules that we have created before.

If you don’t know what all that code here means, you maybe want to watch one of the other videos in our basic video series, or maybe even the premium course might be interesting for you.

You can find that one on our website and there are also more precoded source codes available in our store.

So this is it.

Once you have all three modules in place you can click on the compile button. Here we are.

And if you don’t have any errors you can click on the little button here or press the F4 button to go back to MetaTrader.

And in MetaTrader you want to click on view, strategy tester, or press CTRL and R. Please mark the option for the visual mode here and start your test.

Now our little expert advisor is running.

So the expert advisor seems to work.

Now let’s go to full speed for a few seconds.

You see that we have several positions that are opened. Now let’s pause the whole thing and click on the graph tab.

We have a few positions here.

So it looks like our expert advisor works as expected.

And in this little video you have learned how to create an expert advisor that is able to calculate buy and sell signals by using an external module for the Bollinger Bands.

You also used a filter for the MACD signal and you have coded it all yourself with a few lines of MQL4 code.