In this video, we want to calculate the main signal for this Oscillator here. This is the MACD. It’s very popular. So let’s find out how we can code an entry signal with MQL4.

A separate chart below the candle chart shows the Mac D oscillator.

It has two values that each show a signal value.

In this case, we want to figure out the signal for the main line.

To use it, we create a new MQ4 file and put it in the same directory as the other Platin System files.

The name of the file is CheckEntryMacD.mq4, and it has only one function called CheckEntry.

This function works out the buy and sell signals for our system and sends them back.

In fact, oscillators aren’t made to send signals. They are instead used to confirm or filter out other signals.

But that doesn’t mean we can’t use them, since all we need for our trading system is a clear entry signal.

First, the signal is put into a string variable. But for now we don’t assign a value as we need to calculate it now.

That can be done by using the integrated function called I MacD.

It comes with MQL4 and we need to pass a few parameters.

The first two parameters are for the currently selected symbol on the chart and the currently selected time period on that chart.

Three more values follow to define the period for the fast exponential moving average, then the slow exponential moving average and the signal period.

The values are 12, 26 and 9 as these are the standard values for the MacD oscillator.

Then we need to define that we want to calculate the result based on the close price.

In this example we use Mode_Main to calculate the main signal for the Mac D oszillator.

And the last value is 0 as it is a shift value which is not required.

Now we can calculate the signal by using the Mac D value.

If that number is greater than 0, we want to sell, so we give our signal the word “sell” when that happens.

If the value is less than 0, that means we want to buy, so we’ve given the signal the word “buy.”

And when our function is done, we want to send the MacD signal back to our main module, which has the OnTick function.

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

The compilation is done in the main module, but before you do that, you need to find the include statement for the entry signal and change it to use our new file, CheckEntry MacD.mq4.

You can turn off other entry modules by putting two slashes at the beginning of a line.

By the way, you can also use this entry signal file in your own system, if you have one.

Then, press F7 or click the compile button to compile your main module and the entry signal file that came with it.

No error messages should come up.

If you have trouble, you might want to buy the Premium course or watch one of the beginner videos to learn how it works.

Okay, by now, you should have working entry signal for the MACD Oscillator. So this is it for this video. And I will see you in the next one.