In this little video, we are going to calculate an entry signal for this Oscillator that is called the DeMarker Oscillator. It is not so well known, but we will create an entry signal for it. So let’s see how we can do that with MQL5.


A separate window below the candle chart shows the Demarker oscillator.


It has a scale and two lines.


Most of the time, oscillators are used to filter other signals, but they can also be used to make entry signals, which is what we’ll do here.


To use it, we need to create a separate MQ5 file and put it in the same folder as the other Platin System files.


CheckEntry iDEMARKER mq5 is the name of the file, and CheckEntry is the only function it has.


It will figure out what our entry signal is and send that info back to the main module.


We want to make a string variable for the calculated signal, but we won’t give it a value yet because that will be figured out later.


We need a price array. Please choose the type double as it can hold floating type values.


MQL5 includes a function called iDEMARKER that we can use to define our oscillator.


A few parameters need to be set. The first parameter is the chart’s symbol. The period on the chart is the second parameter.


And the last parameter is used for the number of candles we want to use for our calculation.


When you drag the Demarker oscillator onto one of your charts, you will also see these values.


Now we use array set as series to sort the array that we have created from the current candle 0 downwards.


With CopyBuffer, we put data into the array. We do it  according to our definition from above and calculate values for buffer 0, beginning with the current candle 0 and the next three candles.


Let’s keep going and figure out the current candle’s value by looking at the value of candle 0 in our array. With Normalize Double we can format the value to show 3 digits behind the dot.


To figure out when to buy, we look for a value that is below the lower line. That would be the case then it is below 0.3 !


So it would be a buy signal, and when that happens, we give our signal the word “buy.”


Otherwise, if the value is above 0.7 or above the upper line of the oscillator scale that would be a sell signal, so we put the word “sell” into our signal.


At the end of the function, the signal is sent back to the main module using the return command.


Please don’t forget to save the file!


You don’t need to compile it right now. Just save it and go back to where the OnTick function is in the main module.


There, you need to add the new file to the section that contains the include statements. Using the include statement, followed by the name of the file we have created.


Please use two slashes to comment out any other entry signals, and press F7 or click the Compile button to compile both the main module and the new entry file you just made.


Okay, I hope that the compilation process has worked for you. You should now be able to use the DeMarker Oscillator either as an entry signal or as a filter.


Thank you for watching this video, and I will see you in the next one.