MQL5 Tutorial

MQL5 Tutorial

By Raimund BauerBusinessTechnologyInvesting
Download on the App Store

All MQL5 Tutorial episodes

  • MQL5 TUTORIAL – SIMPLE AMA STANDALONE EXPERT ADVISOR
    This time we are going to calculate the Adaptive Moving Average Indicator; this is the red line you see on the chart. Whenever the candles are above the line we have a buy signal, otherwise if the candles are below the red line this is a sell signal. Now we are going to find out how to create an Expert Advisor in MQL5 that is actually going to trade the Advanced Moving Average. To do that please click on the little button here or press F4 in Metatrader and now you should see the Metaeditor window and here you want to click on: “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file: “SimpleAMAStandaloneEA” (Expert Advisor), click on: “Continue”, “Continue” and “Finish”. Now let’s delete everything above the “OnTick” function and please also remove the two comment lines. We start by including the file: “Trade.mqh”, that file contains a few useful functions and now we can create an instance of “CTrade” that will be called: “trade” and we are going to use it to open positions later on. First we calculate the Ask price and the Bid price by using “SymbolInfoDouble” for the current symbol on the chart, “SYMBOL_ASK” will deliver the Ask price, “SYMBOL_BID” will deliver the Bid price and with “NormalizeDouble” and “_Digits” we automatically calculate the right number of digits behind the dot because this currency pair would have 3 digits while this one has 5 digits and this function (_Digits) is going to handle that. We create an array for the prices by using “MqlRates”, let’s call that array: “PriceInfo”, now we sort the price array (PriceInfo) from the current candle downwards by using the “ArraySetAsSeries” function, we use “CopyRates” to fill the array with price data for the symbol that is currently selected on the chart and the current period on the chart. We start with candle 0 (zero) for 3 candles. Candle 0 (zero) is the current candle. Let’s create a string variable for the signal, we will call it: “signal” and we don’t assign a value here that is going to be calculated now. We need another array (myPriceArray), this one for several prices that contain the Indicator values; the one here was just for the candle prices (PriceInfo). Let’s define the properties for the Adaptive Moving Average value (AdaptiveMovingAverageValue) that is done by using the “iAMA” – it’s an included function in MQL5 – once again for the current symbol and the currently selected period on the chart. You will see three values here; 9, 2 and 30 and when you right click the Indicator and select “Properties” you would see that is calculated for 9 candles, the “Fast EMA:” is 2, the “Slow EMA:” is 30 and the “Shift:” is 0 (zero), that’s exactly what we are using here and the calculation will be based on the close prices. Now let’s sort the second array from the current candle downwards, once again we use “ArraySetAsSeries”, with “CopyBuffer” we fill our price array (myPriceArray) according to the Adaptive Moving Average definition (AdaptiveMovingAverageDefinition) we have created here for the first buffer – that’s the first signal – from candle 0 (zero) for 3 candles and store the result in our price array (myPriceArray). To get the value for the current candle we just look at candle 0 (zero) in our price array (myPriceArray) and with “NormalizeDouble” and the 6 we calculate the current value, as you can see here it has 6 digits behind the dot and if the Adaptive Moving Average value (AdaptiveMovingAverageValue) is above the close price for candle 0 (zero) – that’s actually a shortcut for the current price because close prices are always the last price for a finished candle and candle 0 (zero) isn’t finished so the close price will deliver the current price here – and if this expression is true we want to assign the word: “sell” to our signal. In the other case if the Adaptive Moving Average is below the current price that’s a buy signal and now we assign the word: “buy” to our signal.
    8 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – PARABOLIC SAR INDICATOR
    In this video, we want to create a file for the entry signal of this interesting indicator with the little dots here. This one is called the parabolic SAR. So let’s find out how we can calculate that with MQL5.   This time we want to create an entry signal for an indicator that is painted right above or below the candles.   It is called the parabolic SAR and you will see little dots above or below the current price.   To get started, we want to create a new file called CheckEntry_SAR and save it in the same directory where the other files for the system are located.   The file uses one function called CheckEntry to calculate the signal which will be returned to the main file at the end of the function.   First we use MQLRates to create a price array.   Then we use Array set as series to sort that price array from the current candle downwards.   And with copy rates we fill the price array with data for the currently selected symbol on the chart and the period that we have selected on that chart.   We want to start with candle 0, that is the current candle and copy price data for 3 candles.   The price array will hold that data.   So let’s create a signal variable that can hold text values, but don’t assign any values at this stage.   And we need a second array for the indicator data.   We use the function i-SAR for the symbol on the chart and the selected period for parameter 1 and 2.   Parameter 3 is a so-called step value and parameter 4 is a maximum value.   You will see the values 0.02 and 0.2 when you drag the Parabolic SAR indicator onto any of your charts.   Now we use array set as series to sort the SAR array from the current candle downwards.   And with copy buffer we fill the array according to the SAR definition that we have already created.   We do that for buffer 0, starting from candle 0 for 3 candles.   Now we can extract values from our array.   In this case we are interested to get the value for candle 1.   That will calculate the last value of the indicator.   With NormalizeDouble and the number 5 we can format our output to show 5 digits behind the dot.   And if the last SAR value was below the value for the lowest price of candle 1 in our price array, we want to buy and assign the word buy to our signal.   Otherwise, if the last SAR value was above the value for the highest price of candle 1 in our price array, we want to sell and assign the word sell to our signal.   Finally we use the return function to return the calculated value to our main file.   Now please don’t forget to save the file.   Afterwards please switch to the main file and find the part with the include statement for the entry signal.   You can outcomment other entries by adding two slashes at the start of the line.   Please add the include statement for our new file named CheckEntry_SAR and press F7 or click on the compile button to compile both files.   You might see some warnings, but you shouldn’t get any errors.   If you do, please consider watching one of the basic video tutorials first, or maybe the Premium course on our website might also be interesting for you.   I hope that the compilation process was okay. The parabolic SAR indicator is interesting for people who like to watch charts. But now you should have a working function. That’s it for this video. Thank you and I will see you in the next one.
    5 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – RELATIVE VIGOR INDEX
    In this video, we want to calculate the entry signal for this little Oscillator here. It has actually two signal lines, and it is called the Relative Vigor Index. So let’s see how we can create the entry module by using MQL5.    In this video, we’ll show you how to build an entry signal module for the oscillator that is called Relative Vigor Index.   Because oscillators provide values that are distinct from the price values on the candle chart, that indicator will once again be drawn on a separate chart window beneath the candle chart.   In the same directory as the main file and the other entry files, we first create a new file called CheckEntry RVI.mq5.   The function CheckEntry, which returns a string variable for the calculated signal, is contained in this file.   Let’s start by generating the signal. Since that is a string-type variable, it is capable of holding text data.   We currently keep it empty since we must determine the value as shown.   So let’s create two price arrays, one for the first and one for the second line that is shown in the RVI oscillator window.   Afterwards we define our oscillator and use the i RVI function that comes with MQL5.   That will use the current chart symbol, the chosen time period and the value 10 for the definition.   As you might have guessed, the value 10 is the number of candles for the calculation.   Both arrays need to be sorted from the current candle downwards by using array set as series.   Now we want to fill our two arrays with data and we can do that by using CopyBuffer.   In both cases we use the definition that we have created before.   The first parameter is for the buffer, either 0 or 1.   The second parameter is the starting candle 0.   Parameter 3 is for the number of candles that we want, in our case we want 3 candles.   And the last parameter is the target array for both signals.   In the next step we use Normalize double to get a formatted output with 3 digits behind the dot for the current candle 0. We do that for both arrays.   Now that we have the current values for both buffers, we can define a buy and a sell signal.   In our example we want to buy when value 0 is below value 1 and when both values are below 0.   If that is the case, we assign the word buy to our signal variable.   Otherwise, when value 0 is above value 1 and when both values are bigger than 0, we assign the word sell to the variable.   Now that we have calculated the signal, we want to return it by using the return statement.   Please save the file without compilation, the compilation process will be done in the main file.   Please open it and find the include section.   There you can outcomment all other entries by using two slashes.   Add a new line and include the new file called Check_Entry RVI.mq5.   Then you can compile both files at the same time by pressing F7 or clicking the compile button in the tool bar.   The compilation process should work without any error messages, some warnings are expected.   Okay, I hope you have a successfully compiled version by now. For now, I want to say thank you for watching the video, and I will see you in the next one.
    4 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – RELATIVE STRENGTH INDICATOR
    In this video, we are going to create an expert advisor entry signal for this little oscillator here. It is called the Relative Strength Index, and it’s very popular. So let’s find out how we can do that with MQL5.   The RSI oscillator is drawn in a separate window below the candle chart.   It only has one line, which will be our entry signal.   Most of the time, oscillators are used to make filters, but they can also be used to make entry signals, which is what we will do here.   To use it, we make a separate MQ5 file and put it in the same directory as the other Platin System files.   CheckEntry RSI.mq5 is the name of the file, and it only has one function called CheckEntry.   It will calculate what our entry signal is and send that result back to the main module.   We want to make a string variable for the signal file, but we won’t give it a value yet because it will be worked out later.   So, we build a double-type array to hold the different prices.   In the next step, we’ll use the function iRSI, which is part of the MQL5 programming language. And we can use it to define our oscillator.   Four parameters need to be passed.   The first parameter is the symbol on the chart that is selected at the moment.   The second parameter is the time range we’ve chosen on that chart.   The third parameter is for the number of candles that we want to calculate. In our case we use 14 candles.   The fourth parameter is used to define what we want to use for the result. In our case we calculate it for the close price.   The next step is to sort our array by using Array Set As Series. We want to put it in order from the current candle down.   And now, thanks to CopyBuffer, we can fill the price array with the data for the prices.   The first parameter is for the definition we made above.   Parameter 2 is for the first buffer, which is the oscillator’s signal line.   Candle 0 is used for parameter 3, which is the number of the current candle.   The number of candles we want to use in the calculation is the fourth parameter. We use three candles.   And the price array is the last parameter. This is where we want to store these values.   We only need to look at the value for candle 0 in our price array to find the value for the current candle.   With NormalizeDouble and the number 2 we can create a number with two digits.   If that number is greater than 70, we call that a “sell” signal and put the word “sell” into our signal.   If it is below 30, however, we give our signal the word “buy.”   Lastly, we use the return function to send the calculated value back to our main module.   Don’t forget to save the file, please.   You don’t have to compile it! Jjust save it and go back to the main module, where the OnTick function is included.   There, you need to add the new file to the import section. You can do this by using the include statement.   Please uncomment any other entry signals and press F7 or click the Compile button to compile the main module and the new entry file you just made.   Okay, you should now have a version of the oscillator that works. This version is called the RSI oscillator.   You can use it in your own system, or if you have the Platin System or the Robot Trading system, you can import it into those.    By the way, a demo version is now available on PlatinSystem.org.    That’s all for now.   Thank you for watching, and I’ll see you in the next video.   Okay. I hope the compilation process worked for you. If that is the case, you should have a working version for the RSI that you can use to create signals, or you can use it as a filter. For now, I say thank you for watching, and I will see you in the next video.
    5 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – VARIABLE INDEX DYNAMIC AVERAGE
    In this video we want to check out the indicator for this little red line here. It is called the variable index dynamic average. And we want to create an entry module for it. So let’s see how that can be done with MQL5.   This indicator is drawn on the candle chart as it produces values that can be shown inside of the price range of the candles.   To calculate the entry signal, we first need to create a new file inside of the directory where the other files of your system are located.   The name of the file is CheckEntry_IVIDYA.mq5 and we use a simple function named CheckEntry to calculate the signal for the indicator which will be returned at the end of the function.   But first we need to do a few things to actually calculate the signal.   Let’s start with the signal. Please create a variable called signal. It is of the type string, so it can hold text values.   Afterwards we create an Array for price data by using MqlRates.   And to sort that array we use Array set as series. That will sort it from candle 0 downwards.   So far, so good.    Now we want to fill the array. That can be done by using CopyRates and we do it for the current symbol and the currently selected period for that particular symbol.    We want to store prices, starting with the current candle 0, for three candles and the results will be stored in our price array.   Now, please create another array for our Expert Advisor.   This also will be sorted downwards by using Array set as series, like we have done above.   MQL5 has an included function that is called iVIDyA.   We use it with the following parameters.   First we pass the symbol and the period, followed by the values 9,12 and 0.    If you open a Metatrader chart and click on Insert, Indicators, Trend, Variable Index Dynamic Average, you will find that those are the standard values for the CMO period, the EMA period and the shift value.   So let’s continue with the code here and in the last parameter we use PRICE_CLOSE, because we want the result to be calculated based on the close price.   Afterwards we use CopyBuffer for the definition for our Expert Advisor.    We want to calculate the buffer 0, we want data from candle 0 for 3 candles and we want to store the result in our array for the Expert Advisor.   The rest is easy.   When we pick the value for candle 0 inside of our array, we can use that to compare it with the candle prices.   If that value is above the close price for candle 1, we want to buy.   If it is below the close price for candle 1, we want to sell.   So we assign the word buy or sell to our signal variable and use return to return the calculated signal to our main file, which is the one that contains the OnTick function.   Don’t forget to save the file. Compiling will be done in the main file, you just need to save it.   Let’s open our main file now and find the include statement section.   There you want to outcomment other entry signals.   Just add two slashes before the include statement, that will disable them.   Add another line to include the file we have just created and afterwards you can compile the main file and the entry signal module at once by pressing F7.   You can also use the compile button if your toolbar is enabled.   That should not produce any error messages, but if you have errors, please check your file line by line.   If this was too fast for you or if you have no idea what all those code lines mean, you might want to watch a few more basic videos or maybe the premium course on our website might be interesting for you.   Okay, if everything worked well, you should see the indicator on your chart. It is trading in my case. If you have any problems, you can contact me. And in this little video, you have seen how to create an entry signal for this indicator. I can’t even remember the name.   It is called variable index dynamic average. Thank you for watching and I will see you in the next video.
    6 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – MOMENTUM OSCILLATOR
    In this video, we are going to   create an entry module for this oscillator here. This is called the momentum oscillator.   It is shown on a separate chart below the candle chart.   So let’s find out how to calculate that with MQL5.   In this video we want to create an entry signal module for the so-called momentum oscillator.   That is once again an indicator that will be drawn on a separate chart window below the candle chart, because oscillators create values that are different from the price values on the candle chart.   To get started we create a new file named CheckEntry_Momentum.mq5 in the same directory where the main file and the other entry files are located.   This file will contain the function CheckEntry which will return a string variable for the calculated signal.   Let’s first create the signal. That is a variable of the type string, so it can contain text values.   For now we leave it empty as we need to calculate the value as follows.   We want to store some price data in an array, so we create that first.   To define the momentum oscillator, we can use the function iMomentum.    That is included in MQL5 and it needs a few parameters that we need to define.   Parameter 1 is for the symbol on the chart.   The second parameter is for the period on that chart.   Parameter 3 is the number of candles that we want to use for the calculation.   In our case, we will use 14 candles.   That is also the default value that you will see when you drag the momentum indicator onto one of your charts.   Finally, we use PRICE_CLOSE to calculate the value based on the close prices.   Afterwards we use Array set as series. That will sort the array from the current candle downwards.   And now we can use CopyBuffer to fill the array with data.   We do it for the definition that we have created, for buffer 0 and we want to do it from candle 0 and for three candles.   The result is stored in the price array.   And now that we have done that, we can calculate the current value for the momentum.   All we need to do is to look at the value for candle 0 in our array.   As the momentum indicator has two digits behind the dot, we use Normalize Double and the value 2 to create a formatted output.   Now let’s calculate the signal.   If the momentum value is below 100 we consider that to be a buy signal.   So we assign the word buy to our signal.   Otherwise, when the momentum value is above 100, that’s when we want to assign the word sell to our variable, because that is when we want to sell.   At the end of the function we use return to return the calculated result to our main module.   Now please save your entry file if you not already have done that.   Compilation is not necessary, it will be compiled together with the main module.   Therefore we open our main file and go to the include section where we can outcomment other entry signals by adding two slashes.   Instead of the old entry signal, we now add  an include statement for our new file CheckEntry_Momentum.mq5.   Afterwards we compile the whole thing, by pressing F7.    You can also click on the compile button on the toolbar.   That should work without any error messages.   Otherwise please check out the basic videos about compilation or maybe the Premium course on our website might be interesting for you.   OK, that’s it for the momentum oscillator calculation.   I hope it works for you.   Thank you for watching and I will see you in the next video.
    5 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – MACD OSCILLATOR
    In this video, we want to check out this Oscillator here. It’s a very popular one. It is called the MACD Oscillator. We want to calculate the main signal for this one. So let’s find out how this is done with MQL5.   The Mac D oscillator is shown on a separate chart below the candle chart.   It has two values that show a value as a signal.   In this case we want to calculate the main line signal.   To use it, we build a separate MQ5 file and put it in the same directory as the other Platin System files.   CheckEntryMacD.mq5 is the name of the file, and it only has one function called CheckEntry.   The buy and sell signals for our system are calculated and returned by this function.   In fact, oscillators aren’t meant to make signals. Instead, they are 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 and well defined entry signal.   We start by putting the signal into a string variable.   That will be sent back to our main function later, but first we have to calculate it.   We also have to make an array for data about prices.   And with ArraySetAsSeries, we arrange our array and we want to sort it from the current candle 0 downwards.   MQL5 comes with an included function to calculate the MacD and that function is called I MacD.   We pass the symbol as the first parameter, followed by the period that is currently selected on our 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.   The last parameter is used to define how the signal should be calculated.   We want to use PRICE_CLOSE here to use the close price.   With CopyBuffer we will now fill our array, according to the definition that we have created.   We do that for buffer 0 as that is the main buffer for the MacD oscillator.   We want to start with the current candle, that is candle 0.   And we want to store the value for 3 candles, the target is our price array.   Now that we have done that, we can calculate the current value by looking at the value of candle 0 in our price array.   If that value is bigger than 0, we want to sell and that is when we assign the word sell to our signal.   If the value is below 0, that would mean that we want to buy, therefore we now assign the word buy to the signal.   And at the end of our function we want to return the MacD signal to our main module, which is the one with the OnTick function.   Please don’t forget to save your entry file, but you actually don’t have to compile it right now.   The compilation is done in the main module, but before you do that, find the include statement for the entry signal and change it to use our new file, CheckEntry MacD.mq5.   By putting two slashes at the beginning of a line, you can comment out other entry modules.   After that, press F7 or click the compile button to compile your main module and the entry signal file that came with it.   There shouldn’t be any problems.   If you run into problems, you might want to buy the Premium course or watch one of the beginner videos to learn how it works.   OK, by now, you should have a working version for this entry signal for the MACD Oscillator. If you want to, you could also calculate the difference between the main line and the signal line here. But in this little video, you have learned how to calculate the main module for the MACD Oscillator. I will see you in the next video. Thank you for watching.
    5 min
  • MQL5 TUTORIAL – PLATIN SYSTEM ACCUMULATION DISTRIBUTION OSCILLATOR
    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.
    5 min
  • MQL5 TUTORIAL – WHY THE ONINIT FUNCTION WILL NOT SAVE YOU
    In this video, I’d like to talk about something that seems so obvious that it’s almost blinding.   When you use the strategy tester to test something, you might miss things that are important when you trade in real time.   This is an example of that.   When you test your strategy, you probably forget one or two things that could hurt you when trading in real time.   The first thing is that real time conditions are not the same.   When you’re using the strategy tester, you might not have a lot of different conditions, but that’s part of the game when you’re trading in real time.   If you lose power or have trouble connecting to the internet, your Expert Advisor might not work for a few hours or even days.   That happened to us a lot.   And if there’s one thing that’s likely to happen, it’s that one of these power outages will happen at the worst time and in the worst way.   It could happen while you are on vacation, for example. What happened a few years ago is as follows.   The Expert Advisor knew what the last price to buy was and what the last price to sell was, but then it was disconnected.   During the outage, the market changed, but the Expert Advisor didn’t notice.   Later, the Expert Advisor kept making decisions based on conditions that were no longer true.   You can’t simulate a 7-hour internet outage in a strategy test, so that’s not tested in backtests.   People were very hard on me when I first started using MQL4 because I didn’t use the OnInit function.   Yes, it takes more processing power to figure out everything every time a new Tick comes in.   But it is worth the CPU time when you want to avoid values and assumptions that don’t match up.   Think of something from the real world.   You might have ended up wearing the wrong clothes because the weather changed while you weren’t paying attention.   For example, you might come home from a summer vacation and find that a T-shirt is not enough because the airport in your home country is covered in snow.   The OnInit function will only run once, when the Expert Advisor starts up, so it is a good idea to check every time the price changes to see if some important conditions are still true.   In our Platin System, we do this with a function called CheckForTick.   If you only use one file and don’t import any libraries, you can use your own Expert Advisor right in the MQL OnTick function.   And don’t just go by the results of strategy tests. Those are good ways to tell if something will work or not.   But nothing beats trading in real time, even on a Cent account.   So, when you trade in real time, make sure you check the conditions and assumptions you have, because as Mark Twain once said:   “It’s not what we don’t know that gets us into trouble. It’s the things we know for sure that aren’t true.”
    4 min
  • MQL5 TUTORIAL – PLATIN SYSTEM – ACCELERATOR OSCILLATOR
    In this video, we are going to create an Expert Advisor to create an entry signal for this Oscillator here. It’s the Accelerator oscillator. So let’s find out how to do that with MQL5.   The Accelerator oszillator is drawn on a separate window below the candle chart.   It has a single line which we will use for our entry signal.   Oscillators are usually used to create filters, but it is also possible to create entry signals like we will do in this case.   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_IAC.mq5 and it contains a single function that is called CheckEntry.   It will calculate our entry signal and return it to the main module.   We want to create a string variable for the signal file and for now we will not assign any value as this is going to be calculated now.   Therefore we create an array of the type double to hold several prices.   In the next step we will use the function iAC that is included in the MQL5 language to create a definition for our oscillator.   We only have to pass two parameters here.   The first parameter is for the current symbol on the chart.   The second parameter is for the time period that we have selected on that chart.   In the next step we use ArraySetAsSeries to sort our array. We want to sort it from the current candle downwards.   And with CopyBuffer we can now fill the price array accordingly.   Parameter 1 is for the definition that we have created above.   Parameter 2 is for the first buffer, the signal line of our oscillator.   Parameter 3 is for the starting candle, here we use candle 0.   Parameter 4 is the number of candles that we want to use for the calculation.   And the last parameter is the price array where we want to store those values.   To get the value for the current candle, we simply have to look at the value for candle 0 in our price array.   If that value is above 0, we consider that to be a buy signal and assign the word buy to our signal.   Otherwise, if it is below zero, we assign the word sell to our signal.   Finally we use the return function to return the calculated value to our main module.   Please don’t forget to save the file.    Compilation is not necessary, just save it and go back to the main module which contains the OnTick function.   There you need to add the new file in the import section where you can do that by using the include statement.   Please outcomment any other antry signals and press F7 or click on the Compile button to compile the main module and the new entry file that you have just created.   Okay, by now, you should have a working version for the oscillator that is called the Accelerator.   You can use it in your own system, or you can import it into the Platin System or into the Robot Trading system, if you have one of those. By the way, by now we have a demo version available on Platinum System.org. For now that’s  it.   Thank you for watching and I will see you in the next video.
    5 min