MQL5 Tutorial

MQL5 Tutorial

By Raimund BauerBusinessTechnologyInvesting
Download on the App Store

All MQL5 Tutorial episodes

  • MQL5 TUTORIAL – SIMPLE SIGNAL STACKING
    In this video I wanted to talk about something that I call: “Signal Stacking”; you see 4 lines here, each is a Moving Average for a different period. As long as all the 4 lines are going downwards without a crossover that would be a pretty stable sell trend and you could stay in your short position and be very sure that you don’t lose any money, in fact we would have made some money here, probably a descent amount. The only thing you need to wait for is: you need to wait for a crossover for one or more of these lines to get out. Let’s speed that up a little bit and here is the crossover, now you would get out and when you see a complete crossover for each of the lines like in this case that would create a reverse trend, this is a very good example and now you would open a long position and trade it until the next crossover takes place. Now we want to find out how we can create an Expert Advisor that is able to produce these 4 lines and create buy or sell signals for stable trends. To do that please click on the little button here or press F4 in your Metatrader. 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 one: “SimpleSignalStacking”, click on “Continue”, “Continue” and “Finish” and now you can delete everything above the “OnTick” function and the two comment lines. We want to start by creating an empty string for the signal that will be also called: “signal” and we don’t assign a value here. Let’s create an array for several prices; in fact we are going to create four. We will call them my Moving Average array 1 (myMovingAverageArray1), my Moving Average array 2 (myMovingAverageArray2), my Moving Average array 3 (myMovingAverageArray3) and my Moving Average array 4 (myMovingAverageArray4). For each of the arrays we use the “iMA” function for the current symbol and the current period to create an Exponential Moving Average by using “MODE_EMA” that will be calculated on the close price and it will be calculated based on the current candle. The first Moving Average will be for the last 50 candles, the second one for the last 100 candles, the third one is for the last 150 candles and the last one calculates the last 200 candles. By using “ArraySetAsSeries” we are going to sort each of our arrays from the current candle downwards; this is array 3 and this is array 4, I simply used “copy and paste” that saves some typing work. Now we fill each of our arrays by using “CopyBuffer”. According to the Moving Average definition (movingAverageDefinition) that we have created here each of our EMA’s has only 1 buffer, that’s buffer 0 and we want to fill our array from the current candle 0 for 3 candles and store the result in our Moving Average arrays (myMovingAverageArray) and now we can calculate our Moving Average values (myMovingAverageValue) by looking into candle 0 of our Moving Average arrays (myMovingAverageArray). These are the values and when you place your mouse over each of the lines at the end of the line you will see the current value for candle 0 and to calculate the sell signal we would check if “myMovingAverageValue1” is below “myMovingAverageValue2” and if “myMovingAverageValue2” is below “myMovingAverageValue3” and if “myMovingAverageValue3” is below “myMovingAverageValue4”. So, these 3 “if” statements stack our entry signals and only if all are true we would create a sell signal. For the buy signal it’s almost exactly the same but in this case we are checking if the value for each of our Moving Averages is greater than the one on the right side. If this is the case we create a buy signal. In the last step we use the ”Comment” function to output our signal on the screen followed by each of the values that we have calculated. Okay. When you are done please click on the “Compile” button here, that should work without any errors and without any warnings and if this is the case please click on the little button here ...
    7 min
  • MQL5 TUTORIAL – SIMPLE ICCI EXPERT ADVISOR
    In this video we are taking a look at the ICCI Indicator, that’s the Commodity Channel Index Indicator. You can see that this signal here is creating buy and sell signals and whenever the blue line here is above the upper dotted line that would be a sell signal, in the other case if the blue line here is below the lower dotted line that would be a buy signal. Now, how can we create an Expert Advisor that is able to calculate the Commodity Channel Index Indicator? To do that please click on the little button here or press F4 on your keyboard 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 one: “SimpleCommodityChannelIndex”, click on “Continue”, “Continue” and “Finish” and now you can delete everything that is above the “OnTick” function and let’s also delete the two comment lines here. Here we need to create a string for the signal that will be also called: “signal” but we don’t assign any value here. We also need to create an array for the price data that will be called: “myPriceArray”, it’s a double array so it can hold floating type values and now we define the ICCI Expert Advisor by using the “iCCI” function that is built in into MQL5, it uses a few parameters; the first one is for the current chart – we use “_Symbol” to get the current currency pair on the chart and “_Period” to get the currently selected period. Right now we are trading the 1-minute chart but another period could be 30 or 60 minutes, the third parameter is the number of the candles. We use 14 candles and if you click on: “Insert/ Indicators/ Custom/ CCI/ Inputs” you would see a period of 14 candles is the default value. When I click on “OK” that’s what we see within the round brackets here, let’s right-click and select “Properties”, go to the “Parameters” tab until you see that we use a typical price and in MQL5 that’s “PRICE_TYPICAL” for the last parameter and now that we have defined the ICCI we want to use “ArraySetAsSeries” to store the price data from the current candle downwards for our price array (myPriceArray) we have created here and with “CopyBuffer” we fill our price array (myPriceArray) according to our “ICCIDefinition” for buffer 0 from the current candle 0 and for 3 candles and to get the ICCI value (ICCIValue) we just need to have a look at candle 0 in our price array (myPriceArray) and we assign the result to the variable ICCI value (ICCIValue) and whenever the ICCI value (ICCIValue) is greater than 100 that would be considered to be a sell signal so we assign the word: “sell” to our signal. In the other case if the ICCI value (ICCIValue) is below -100 that would be a buy signal so we assign the word: “buy” to our signal. Now let’s make that a capital and in the last step we want to create an output on the chart that will output the word “Signal:” followed by the calculated signal. Please don’t forget the closing bracket. I will enable the toolbar so now I can click on the “Compile” button here or press F7 on the keyboard to compile the code. We have one warning here because we used the float value here, usually that would be a double value so let’s correct that, press F7 and now the warning is gone, it doesn’t really make a difference because we use the ICCI value (ICCIValue) to find out if something is above 100 or below -100, you can store a lot of digits behind the dot in double value but that’s not very helpful if you just want to find out if something is above plus or below minus 100. Okay, if you could compile your code without any errors you could now click on the little button here or press F4 on your keyboard to go back to Metatrader. In Metatrader you want to click on “View/ Strategy Tester” or press CTRL and R on your keyboard and here in a Strategy Tester please select the “SimpleCommodityChannelIndex.ex5” file, mark the visualization option here and start your test and here’s our little Expert Advisor at work it c...
    6 min
  • MQL5 TUTORIAL – SIMPLE POSITION MULTIPLIER
    In this video we are going to create a Simple Position Multiplier, right now we are trading 5 positions and in this video we are going to find out how to code something like this in MQL5. To do that please click on the little button hero press F4 on your keyboard, 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: “SimplePositionMultiplier”, click on “Continue”, “Continue” and “Finish” and now you can remove everything above the “OnTick” function and the two comment lines here. The first thing we need is to import the trade library; that’s the file: “Trade.mqh” and we are going to create an external variable that can be adjusted by the user. To do that we use the input modifier, it’s an integer variable with the name: “NumberOfPositions” and the default value will be 1 position that is allowed. In the “OnTick” function we first need to get the “Ask” price. The “Ask” price is the price that we have to pay if we want to buy something and we get it by using “SymbolInfoDouble” for the current symbol and “SYMBOL_ASK” will provide the current ask price while “SYMBOL_BID” would give us the “Bid” price. The “Bid” price is the price you get when you want to sell something and with “NormalizeDouble” and “_Digits” we make sure that we have the right number of digits behind the dot. You see we have currency pairs with 5 digits behind the dot and other currency pairs with 3 digits behind the dot. Let’s use “MqlRates” to create a price array (PriceArray), that will be used to store our prices. With “ArraySetAsSeries” we sort our price array (PriceArray) from the current candle downwards and now we can fill it with price data; that is done by using “CopyRates” for the current symbol and the currently on the chart selected period to fill our price array (PriceArray) from the current candle 0 for 3 candles. If the last close price is higher than the close price before – so that would be the case if the close price for candle 2 is lower than the close price for candle 1 – we check if the number of trades is below the number of positions. That is done by using the built-in function: “PositionsTotal”; that will give us the number of the open positions and if the result is below the number of positions that we have defined here we will open a simple buy trade for 10 micro lots and set the “take profit” value to 150 points, that’s about it. If you are done you can click on the “Compile” button here… Oh, I missed something… I need to create an instance for “CTrade”, so let’s do that and re-compile the code and this time it works. If that is the case for you please click on the little button here or press F4 on your keyboard to go back to Metatrader. In Metatrader click on “View/ Strategy Tester” or press “CTRL and R”, we select the “SimplePositionMultiplayer.ex5” file we just have created. Now click on the “Inputs” tab and change the variable: “NumberOfPositions” to 10, and here we are, our Expert Advisor is trading lot of positions at the same time and now you know how to create an Expert Advisor where you can adjust the number of positions that should be traded and you have coded it yourself with a few lines of MQL5 code.
    5 min
  • MQL5 TUTORIAL – ADVANCED STOCHASTIC EXPERT ADVISOR
    In this video we are going to create an Expert Advisor for the Stochastic Indicator, this is the Stochastic Oscillator, you see two lines and they are creating buy or sell signals. Whenever we see a crossover below the dotted line here that would be a buy signal and when the two lines cross above the upper dotted line that would be a sell signal. Now how can we create an Expert Advisor using the Stochastic Oscillator in MQL5? To do that please click the little button here or press F4 on your keyboard and now you should see the Metaeditor window and here we want to click on “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file: “CheckEntry_Stochastic”, click on “Continue”, “Continue” and ”Finish” and now you can remove everything above the “OnTick” function and the two command lines here; basically the “OnTick” function is called whenever we have a price change on the chart but we are going to return the entry signal to our main module – in my case this main module is the Forex Trading Framework, it’s a collection of functions to open at handle trades –, you can also use your own main module. In my case I’m going to include the “CheckEntry_Stochastic.mq5″ file that we are creating here and I use a function called: “CheckEntry” to get the entry signal, so let’s call our function string “CheckEntry” because it will deliver a string, that string will have the name: “Signal”, right now we don’t assign a value because we need to calculate that later on. We also need two arrays; the K array (KArray) and D array (DArray), both arrays are double arrays so they can hold floating type values and we sort the arrays by using “ArraySetAsSeries” from the current candle downwards and after that we create the Stochastic definition (StochasticDefinition) by using the ”iStochastic” function. The first parameter is for the chart we use, the second one for the period we have selected on the chart. Now what are these values: 5, 3, 3 and MODE_SMA here? Let’s click on “Insert/ Indicators/ Oscillators/ Stochastic Oscillator” and here you will see that the K period is 5, the D period is 3, we have a slowing value, the method is simple and the value for the price field is low and high and that’s what we are using here; K period, D period, slowing mode for Simple Moving Average and the low-high value for the price field. Okay. Let’s fill the array with price data that is done by using “CopyBuffer”. The K array (KArray) uses buffer 0, the D array (DArray) uses buffer 1 and we want to fill our arrays for 3 candles starting at candle 0 – that’s the current candle that is built on the chart – and now that we have done that we can calculate the value for the current candle by looking at candle 0 for the K array (KArray) and we will assign that value to K Value 0 (KValue0) and afterwards we look at candle 0 in the D array (DArray) and assign the result to D Value 0 (DValue0). Now we have the values for candle 0 and we do the same for candle 1 because whenever we have a crossover here we need the values for candle 0 and candle 1. Let’s do that for a buy signal; if the K Value 0 (KValue0) is below 20 and the D Value 0 (DValue0) is below 20 – that would be the case when both values are below the dotted line here – we check if the K Value 0 (KValue0) is now bigger than the D Value 0 (DValue0) and if the K Value 1 (KValue1) was below the D Value 1 (DValue1); if this statement is true we have a crossover below the lower dotted line and now we want to assign the word: “buy” to our signal. In the other case if both values are above 80 – that’s the upper dotted line here – we check if the K Value 0 (KValue0) is now below the D Value 0 (DValue0) and if the K Value 1 (KValue1) was above the D Value 1 (DValue1), that would also be a crossover above the upper dotted line and now we assign the word: “sell” to our signal. The last thing we need to do is to use the “return” function to return our signal to the main module,
    7 min
  • MQL5 TUTORIAL – SIMPLE MODULAR EXPERT ADVISOR
    In this video we are going to find out how to create an Expert Advisor that is able to import other files. In our case we are trading the MACD entry here, now let’s stop the test and start it again and this time it’s the Accelerator Indicator. This is the same main module and now we are going to find out how we can create an Expert Advisor that is able to trade and import different entry signals in MQL5. To do that please click on the little button here or press F4 in your 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 one: “SimpleModule” click on “Continue”, “Continue” and “Finish”. Now we can delete everything above the “OnTick” function and we can remove the comment lines and before we start with the “OnTick” function we want to include an external file. In our case it is an external file that can create a trading signal it’s called: “CheckEntry_IAC” and you will find everything here in another video and we use the include function to import the “CheckEntry_IAC” file that is located in the same directory than the simple module file (SimpleModule). In the “OnTick” function we get a string signal from the external file so we create a string variable called “signal” and we call a function called: “CheckEntry” that is included in the “CheckEntry_IAC” file and it will return the signal. Once we have the signal we want to create an output for the signal on the screen; that is done by using the “Comment” function that will output the word: “signal” followed by the calculated signal and basically that’s it for the simple module. Now let’s click on compile; that worked without any errors and without any warnings, so now we can click on the little button here or press F4 to go back to Metatrader. In Metatrader we click on “View/ Strategy Tester” or press CTRL + R, select the “SimpleModule.ex5” file and start a test. Oh, please make sure to enable the visualization option here and now we see that we get buy or sell signals and this is the Accelerator Oscillator, now stop that test, this is the check entry function for the “CheckEntry_MACD” file, that’s also another video but let’s actually exchange the entry module here. Now we include the “CheckEntry_MACD.mq5” file, compile the same simple module, close the last test, start a new one and here is the MACD entry. Actually it’s that simple to create a simple modular system that can show you the entry signals of different indicators and you have created it yourself with a few lines of MQL5 code.
    5 min
  • MQL5 TUTORIAL – ADVANCED ACCELERATOR ENTRY
    In this video we are going to trade the Accelerator Oscillator, it’s the fast running window here below the candles and the Accelerator Oscillator basically will tell us if something is overbought or oversold, so whenever the zero line is crossed here the signal changes. When the bars are drawn below the zero line we consider that to be oversold and we are going to use it as a buy signal, and when the bars are drawn above the zero line we consider it to be overbought and now we want to sell. It’s profitable right now, so now we want to find out how we can automate the Accelerator Entry. In this case I’m using the Forex Trading Framework as a main module because it is able to handle several trades at the same time and to create an entry module please click on the little button here or press F4. 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 one: “CheckEntry_IAC”, click on “Continue”, “Continue” and “Finish”, and now you can delete everything above the “OnTick” function and the two command lines here. The first thing we need to do is to change the “OnTick” function, it will return a string and we will call it “CheckEntry”. Now we need to create an empty string for the signal; that will also be called “signal”, we don’t assign any value right now because we are going to calculate it later. Let’s create an array for several prices that will be called: “PriceArray” (myPriceArray) and it’s a double array so it can hold floating type values and here comes the definition for the iAC Expert Advisor, we use the function “iAC” that is built in into MQL5. This function just needs two parameters; the first one is for the current symbol on the chart and the second one is for the period we have selected on that chart. Now we use “ArraySetAsSeries” to sort the prize array (myPriceArray) from the current candle downwards and with “CopyBuffer” we fill our price array (myPriceArray) for 3 candles from the current candle 0 for buffer 0 according to the “iACDefinition” we have created here. To get the value of the current candle we can select the candle 0 in our price array (myPriceArray) and the result will be assigned to a float variable called: “IACValue” and if the value is above the zero line – that would be the case when the bars are above the dotted line here – and the “IACValue” is greater than 0 we assign the word “sell” to our signal. In the other case if the value is below the zero line so the “IACValue” is less than 0 we would assign the word “buy” to our signal. In the last step we need to return the signal to our main module by using the “return” function for the signal and in my case the main module is the Forex Trading Framework; that’s a collection of functions and you can basically trade any kind of entry signal with those functions, so I have included the new entry module here. Let’s compile the framework. That worked without any errors and you could also use your own main module and if the compilation worked for you, you can click on the little button here or press F4 to go back to Metatrader. In Metatrader we click on “View/ Strategy Tester” or press CTRL + R and in the Strategy Tester you have to select your main module, in my case it’s the Forex Trading Framework, if you haven’t created your own framework you could also download my version, it’s located on the website: forextradingframework.com. Now we select any currency pair here, enable the visualization mode and start our test and now our Expert Advisor is running, it has already opened several trades and now you know how to create an Expert Advisor that is able to trade the Accelerator Oscillator and you have coded it yourself with a few lines of MQL5 code.
    6 min
  • MQL5 Tutorial – Advanced MacD
    This time we are going to trade an advanced version of the Mac D entry. I will speed the test up a little bit and now you can see that we are trading several positions here and that’s because we are using a framework. This framework basically is a collection of functions that are able to manage open trades and you can use any entry you like. Now how can we create in Mac D entry that can be used for framework? To do that please click on the little button here in Meta Trader and that should open the Meta Editor and in the Meta Editor you want to click on File, New, Expert Advisor from Template, Continue. I will call this one Check Entry_Mac D. Now click on Continue, Continue and Finish. And in this case you can delete everything because we are going to create a new function with the name Check Entry. It is a string function because it will return a string so let’s create an empty string without any value and it will have the name signal. We also need a price array so I would create one of the type double and that will be called My Price Array and now we want to define the properties of the Mac D Expert Advisor and that can be done by using iMac D for the current symbol on the chart and the current period, and these values 12, 26 and 9 can also be seen if you click on insert indicators, Oscillators Mac D. This is a value of 12 for the first EMA, the slow EMA has a value of 26 and the Mac D SMA has a value of 9. The calculation is based on the close price and that’s exactly what we do here so let’s sort our array from the current candle downwards by using array set a series for the price array we have created here and after that we can fill the array by using copy buffer for the Mac D definition and that we have created in this line we use zero for the first line. The current candle also is candle zero, we want to calculate it for three candles that’s the three here and afterwards we want to store the result in our price array. So let’s get the value of the current candle, that would be candle zero in my price array and we store the value in a float variable called Mac D value and if the Mac D value is above zero we want to create a signal for a sell trade because we believe that the Mac D value is overbought and in the other case if the Mac D value is below zero, we create a buy signal. That’s about it, in the last step we want to return the calculated value to the main module by using return signal. Now let’s save the module and now I need to recompile the framework, if you don’t know what a framework is you can think of it as a group of functions that can be imported to manage your open trades. The only thing you have to do is to pick one of the entry signals and in the OnTick function it will check for a signal by calling the check entry function that we have created here and afterwards it calls the trade management and with the check for tick function and the trading framework we will handle the signal and open the trade, that’s a little bit more complicated but in this little video we are just talking about the entry. Okay the compilation of the framework was successful, if you don’t know how to create a framework you might want to take the course on my website to learn it and I will also offer another way to get it in a few weeks so if you’re interested you can find everything about it on my website. Now let’s click on the little button here or press F4 to go back to Meta Trader and in Meta Trader I click on View Strategy Tester or I press control and R. And in the Strategy Tester I choose the Forex trading framework. Let’s pick a whole year, enable the visualisation mode and start the test. And here is how it looks like, I will speed it up a little bit for you and now you can see the results. It’s running pretty fast but I can still speed it up, I only have to disable the visualisation here. Let’s maximize this panel, start the test and here is how it works. And that’s a way to do hundreds or thousands of trades in a fe...
    7 min
  • MQL5 TUTORIAL ADVANCED CHAIKIN EXPERT ADVISOR
    In this video we want to talk about the Chaikin Oscillator it’s the indicator here below the candle chart. You see that it is rapidly running between two extremes and it’s trading on the chart right here. I will speed it up a little bit. This is the graphical representation of the automated trading system; I use the Forex Trading Framework. In this video we are going to create an entry module that is able trade the Chaikin Oscillator automated. To do that please click on the little button here, now you should see the Metaeditor window and this is the Forex Trading Framework. The framework basically is a collection of several functions that can manage the trades and it can also include any kind of entry and this is the one we are going to create now. So please click on “File /New /Expert Advisor” from template (template), Continue (Next). I will have to call this one: “Check Entry Chaikin mq5” (CheckEntyry_Chaikin.mq5). Continue, continue and finish. Now you can remove everything above the “OnTick” function and the two comment lines here. In the “OnTick” function we declare a string variable for the signal – that will be called signal – and we will not have any assigned value because we are going to calculate it later. The next thing we need to do is to create an array for several prices that will be called: “myPriceArray”. We define the properties for Chaikin Expert Advisor by using the built-in function: “iChaikin” that needs to have some parameters; the first one is for the symbol – that’s the current chart, the second one is “_Period” – that is for the period on the chart, we have values of 3, 10, MODE_EMA and VOLUME_TICK here so let’s right click on the Chaikin Oscillator, select properties and you will see that it calculated based on the tick volume, the Fast Moving Average has a value of 3, the Slow Moving Average has a value of 10 and the method is Exponential and that’s exactly what we use here. Now let’s sort the prices in the array from the current candle downwards, that can be done by using “ArraySetAsSeries” for the price array (myPriceArray) and with “CopyBuffer” we fill our price array according to the Chaikin definition (ChaikinDefinition) we have created here. We just have one line, in MQL5 that’s represented by buffer zero, the current candle is also zero and we want to calculate 3 candles – that’s the 3 here – and store the result in our price array (myPriceArray). Now its possible to get the value of the current candle, we will assign it to the variable: “ChaikinValue” and we get it by looking into the value for candle zero of our price array (myPriceArray[0]). We also want to calculate the value of the candle before – that’s candle 1 – because if candle 1 was above the dotted line here and candle 0 is below the dotted line here that would be a crossover. Here it is the other way around; candle 1 was below the dotted line and candle 0 is above the dotted line. How do we do that in MQL5? Well, if the Chaikin value (ChaikinValue) is above zero and the previous Chaikin value (PreviousChaikinValue) is below zero that would create a buy signal so we assign the word “buy” to our signal. In the other case if the zero line is crossed from above the Chaikin value (ChaikinValue) would be below zero and the previous Chaikin value (PreviousChaikinValue) would be above zero and in that case we assign the word “sell” to our signal. In the last step we need to return the signal to our main module by using the “return” function. In my case the main module is the Forex Trading Framework and within the “OnTick” function of the main module we call the Check Entry (CheckEntry) function of the entry module we just have created. Okay. Please save the module. I need to recompile the Framework here. That can be done by clicking on the “Compile” button here or by pressing F7 on the keyboard. Oh, I have messed something up here! This need to be a string function and it needs to have the name CheckEntry because we are calling it he...
    7 min
  • MQL5 TUTORIAL – SIMPLE RECTANGLE OBJECT
    In this video we are going to create an object like the blue rectangle you see on the chart, it’s drawn automatically and it shows you the highest and the lowest candles within the last 30 candles, so you could use it for a trading range. In this video we are going to find out how to do that with MQL5. To create the Expert Advisor please click on the little button here or press F4 on your keyboard, 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 one: “SimpleRectangle”, click on “Continue”, “Continue” and “Finish” and now I can delete everything above the “OnTick” function and the two comment lines here. The first thing we need to do is to create a variable for the highest and the lowest candle. This will hold the number of the candles; for example in this case the highest candle is: candle 0, 1, 2, 3, 4, candle 5. Let’s also create arrays for the highest and lowest candle prices! When you place the mouse over any candle here you will see that for each candle we have open, high, low and close prices and these two arrays here will hold 30 prices for our candles. Let’s use “ArraySetAsSeries” for the high array (High) and the low array (Low) to sort the array downwards from the current candle. To fill the array with the data we need we use “CopyHigh” or “CopyLow”. If you mark “CopyHigh” and press F1 you will learn that it gives you the highest bar prices and “CopyLow” is able to give us the minimal bar prices and we want to do that for the current symbol on the chart and the currently selected period starting from the current candle 0 for 30 candles with “CopyHigh”. We use “CopyHigh” for the highest prices and “CopyLow” for the lowest prices. Everything else is the same and to find the highest candle we use “ArrayMaximum” this one gives you the largest element; meaning the highest of our 30 candles in our high array (High) starting from candle 0 for 30 candles and with “ArrayMinimum” we get the lowest element. In our case the lowest candle in our low array (Low) starting from candle 0 for 30 candles. One more thing we need is to use “MqlRates” to create a price information array (PriceInformation), “MqlRates” will give us all the prices for each and every candle including the high and the low prices. With “ArraySetAsSerious” we sort our price information array (PriceInformation) from the current candidate downwards and with “CopyRates” we fill the price information array (PriceInformation) with data for the current symbol on the chart and the currently selected period. We start at candle 0 and this expression here will give us the price information for all the bars on the chart. Before we create an object we use “ObjectDelete” to delete any rectangles that might have been drawn before. “ObjectDelete” only takes two parameters; the first one is for the chart we are using and the second one is the name of the object. To create our rectangle we need to use the “ObjectCreate” function. This one needs quite a few parameters here; the first one is for the currently selected chart, the second one is the name of the object – you can use any name you like – the third one is the object type. I have used “OBJ_RECTANGLE” that will tell MQL5 what kind of object I need. There are several other object types; like “OBJ_TRIANGLE” or “OBJ_ELLIPSE” or things like a button but in our case we want to draw a rectangle. The third parameter is for the window where it should be drawn, the 0 stands for the current main window – that’s the window with the candles – this expression will help us to draw the left border for candle 30, the upper border should be drawn on the highest price of the highest candle in our price information array (PriceInformation), the right border should be drawn for candle 0 – that’s the current candle here on the right side – and the lower border should be drawn on the lowest price of the lowest candle in our price informa...
    7 min
  • MQL5 TUTORIAL- FREE EXPERT ADVISOR DOWNLOAD ENTRY MODULES
    In this video I wanted to talk about how you can get new entries. Right now we are trading the Bollinger Bands entry, this is the Forex Trading Framework, this is the entry we use and as you can see there are several other entries. This is the main module, here is defined that we are going to use the Bollinger Bands right now, but now I want to change that, actually I have an Advanced Adaptive Moving Average entry, it’s hosted on mql5tutorial.com. When you search on mql5tutorial.com for advanced you should get the newest stuff that is available. These are all trading entry modules you can use for the Forex Trading Framework and here is the download button. If you know how to code an MQL5 main module you could also use the downloads for your own system. All you need to do is to become a free member of mql5tutorial.com to get access to all the downloads, otherwise you might get the “No Access” message, here registration is required to protect the content but you could also login with Facebook, just click on the link. Now I’m logged in, let’s search for the term: advanced, select the Advanced Adaptive Moving Average and click on download. This time it worked, here is the downloaded file, now I just select everything, copy the content, open one of my existing entry modules, save that file as “CheckEntryAdaptiveMovingAverage”, click on save. Now I can out-comment the current entry that was the Bollinger Bands and include the new entry file we have created here, all I need to do is to click on the compile button. That worked without any errors, so let’s stop the current test, start a new one and this time I’m trading the Adaptive Moving Average. This is an easy way to get entry modules for free right from the website: mql5tutorial.com, all you need to do is to search for the term: advanced, become a member, download the entry module you like and create a new module for the entry you would like to trade. You also get a few entry modules from the download page and whenever I have released a new entry module on the website: forextradingframework.com, you will get one of these mails here; like here for the Adaptive Moving Average entry, it contains a complete explanation and links to some other modules like the Momentum Indicator. These videos will teach you how to create the entry modules by coding them in Metaeditor by yourself, so if you stay a member you will have a dozen or more entry modules in a few weeks and you can all test them with the Forex Trading Framework.
    4 min