30 Folgen

With MQL5 and Metatrader5 you can create your own trading robot to trade 24/7 exactly according to your own rules. Learn MQL5 or start with precoded modules that can be adjusted exactly to your own needs.

MQL5 Tutorial Raimund Bauer

    • Wirtschaft

With MQL5 and Metatrader5 you can create your own trading robot to trade 24/7 exactly according to your own rules. Learn MQL5 or start with precoded modules that can be adjusted exactly to your own needs.

    • video
    MQL5 TUTORIAL – SIMPLE AWESOME STANDALONE EXPERT ADVISOR

    MQL5 TUTORIAL – SIMPLE AWESOME STANDALONE EXPERT ADVISOR

    This time we are going to create a standalone Expert Advisor to trade the Awesome Oscillator, it will output buy and sell signals directly on the chart and whenever the line is crossed here we either get a sell signal when it’s below the dotted line or we would get a buy signal as soon as it crosses the line like right now the bars are above and now we consider that to be a buy signal. Now how can we create an Expert Advisor in MQL5 that is able to not only output the signals on the chart but to automatically trade them? To do that please click on the little icon 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 file: “SimpleAwesomeStandaloneEA”, click on “Continue”, “Continue” and “Finish”. Now you can delete everything above the “OnTick” function and the two comment lines here. We start by including the file “Trade.mqh”, this one comes with MQL5 and it makes it possible to create an instance from the class “CTrade” that will be called: “trade” and we are going to use it to open positions later on. Before we do that we calculate the Ask price and the Bid price that is done by using “SymbolInfoDouble” for the current symbol on the chart, “SYMBOL_ASK” will give us the Ask price and “SYMBOL_BID” will give us the Bid price. With “NormalizeDouble” and “_Digits” we automatically calculate the right number of digits because the current currency pair has 5 digits behind the dot but there are also other currency pairs with 3 digits behind the dot. Now we need a signal variable that will be a string variable so it can contain text later on right now we don’t assign any values because we need to calculate them later on. With “MqlRates” we create a price information array (PriceInformation), that function here stores the information about the prices, the volumes and the spread. Now we sort the array from the current candle downwards by using “ArraySetAsSeries” and with “CopyRates” we fill it for the current symbol and the currently selected period on the chart from candle 0 (zero) for 3 candles and we store the data in our price information array (PriceInformation). Let’s create another array called: “PriceArray” that one will hold the data for our Oscillator, so let’s use the integrated “iAO” function of MQL5 to define the Awesome Oscillator Indicator for the current symbol and the current period on the chart. This array (PriceArray) also needs to be sorted from the current candle downwards so we use “ArraySetAsSeries” for this one and now we use “CopyBuffer” to fill our price array (PriceArray) for the first buffer – that’s the line here – from the current candle 0 (zero) for 3 candles and store the information for the Expert Advisor in our price array (PriceArray). And to calculate the Expert Advisor for the current candle we simply look at the value of candle 0 (zero) in our price array (PriceArray), we also use “NormalizeDouble” and a 6 to get six digits behind the dot like here and the result will be stored in the Awesome Oscillator value (AwesomeOscillatorValue) and if that value is above 0 (zero) we consider that to be a buy signal and now we assign the word: “buy” to our signal. Otherwise if the value (AwesomeOscillatorValue) is below 0 (zero), so if the Awesome Oscillator value (AwesomeOscillatorValue) is less than 0 (zero) we assign the word: “sell” to our signal and if the signal equals sell and “PositionsTotal” is below 1 – in other words we don’t have any open position – we use “trade.Sell” to sell 10 micro lot. Otherwise if the signal equals buy and we have no open positions we use “trade.Buy” to buy 10 micro lot. The last thing is to create a chart output by using the “Comment” function to output the text: “The current signal is:” and the calcu

    • 6 Min.
    • video
    MQL5 TUTORIAL – SIMPLE SAR STANDALONE EXPERT ADVISOR

    MQL5 TUTORIAL – SIMPLE SAR STANDALONE EXPERT ADVISOR

    In this video we are going to create a standalone Expert Advisor that is actually able to trade the Parabolic SAR Indicator. This is a very nice Indicator, you can see the dots above and below the price and whenever the direction changes here you will see that we have a buy or a sell signal. The signal output will be in the left upper corner here; this Expert Advisor will be able to automatically trade the signal. We have already an open position here and now we want to find out how we can code such a standalone Expert Advisor in MQL5. 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 version: “SimpleSARStandaloneEA” (Expert Advisor), click on: “Continue”, “Continue” and “Finish”. Now we delete everything that is above the “OnTick” function and let’s also remove the two comment lines here. We start by importing the file: “Trade.mqh” that will enable us to create an instance of “CTrade” that will be called: “trade” and we use it later on to open the positions. Inside the “OnTick” function we create a price array (PriceArray) that is done by using the “MqlRates” function that is included in MQL5, now we use “ArraySetAsSeries” to sort our price array (PriceArray) from the current candle downwards and with “CopyRates” we fill it for the current symbol on the chart and a currently selected period, we start with the current candle 0 (zero) and we copy price data for 3 candles and store it in our price array (PriceArray). We also need to create a string for the signal, that variable will be also called: “signal” and we don’t assign a value here because we are going to calculate that later on. First we need to get the Ask and the Bid price, that can be done by using “SymbolInfoDouble” for the current symbol, we use “SYMBOL_ASK” to get the Ask price and “SYMBOL_BID” to get the Bid price, and with “NormalizeDouble” and “_Digits“ we calculate the number of digits behind the dot – you see that this currency pair has 3 digits while other currency pairs may have 5 digits – and if you mark “_Digits“ and press F1 you will see that the “_Digits“ variable stores the number of digits after the decimal point. Let’s create another array for our SAR Indicator that will be called my SAR array (mySARArray), it’s a double array so it can hold floating type values and by using a “iSAR” we create an SAR definition (SARDefinition) for the symbol on the chart and the currently selected period. Now you might ask yourself; what these two parameters are? Well, if you click on “Insert/ Indicators/ Trend/ Parabolic SAR” you will see that we have a step value of: 0.02 and a max value of: 0.2, that’s exactly what we are using here. Now it’s time to sort the SAR array (mySARArray) with “ArraySetAsSeries” and we use “CopyBuffer” one more time to fill our SAR array (mySARArray) for the first buffer – that’s the one that is used for the dots here – from the current candle 0 (zero) for 3 candles and store the values in our SAR array (mySARArray). Now we are able to calculate the value for the last candle, I will call it: “LastSARValue”, I use ”NormalizeDouble” here and a 5 because when you pause the Strategy Tester and hold your mouse above one of these dots you will see that we have 5 digits behind the dot of the value – that’s what “NormalizeDouble” does; if I would use “NormalizeDouble” and a 4 we would have 4 digits behind the dot – and we get the value for the last candle by looking at candle 1 in our SAR array (mySARArray). We actually do the same here, this time for candle 2 – that’s the candle before the last candle – so I call it: “NextToLastSARValue” and whenever the “LastSARValue” is below the lowest price of

    • 7 Min.
    • video
    MQL5 TUTORIAL – SIMPLE ICCI EXPERT ADVISOR

    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 “SimpleCommodity

    • 5 Min.
    • video
    MQL5 Tutorial – Simple Adaptive Moving Average Robot

    MQL5 Tutorial – Simple Adaptive Moving Average Robot

    Okay, this time we are talking about an Adaptive Moving Average Indicator. It was created (I think) by Perry Kaufman and you can use it to find entries or exits like you could with a simple moving average. Now if that is almost the same, why should we prefer to use an Adaptive Moving Average? Well Perry J. Kaufmann created this fascinating formula here for a reason. The Adaptive Moving Average has less lagging and generates less false signals. Let’s see if that is true. Now how can we create an Adaptive Moving Average Expert Advisor for Meta Trader 5? First please click on the little button here, that should bring up the MetaEditor. And here you want to select File, New, Expert Advisor from template, Continue and we will call that Simple Adaptive Moving Average. Now click on Continue, Continue, finish, and you can remove everything above the Ontick function here and I will also delete the two comment lines. So let’s create an array that will hold our prices, I will call it my price array and it is a double array because double and float variables can hold floating point types. And the adaptive moving average has six digits behind the dot and now we want to use the integrated MQL5 function iAMA for the current symbol on the chart and the current period, we want to calculate our prices based on the last nine candles. The Fast Moving Average has a value of two because if you Insert, Indicators, Trend, Adaptive Moving Average, you will see the values here, these are the nine candles. The fast EMA, that’s an Exponential Moving Average, is calculated for two candles and the slow EMA is calculated for thirty candles. And we do not need any shift, so we will use the exact same values here: nine candles, two candles for the fast EMA, thirty candles for the slow EMA. Zero for no shift and I would like to have the values calculated based on the close prices because the close price is also the default setting here. Okay let’s move on and sort the price array from the current candle downwards by using the array set as Series function for the price array we have created here. And now we want to fill it with data, that is done by using Copy Buffer for the Defined Moving Average, that’s the Adaptive Moving Average Definition we have created in this line. We just need one line, that’s the zero here, and we want to copy values from the current candle that’s candle zero for three candles that’s the three here, and we want to store the results in our price array. And now what we have done that, we want to get the value of the current candle, that’s candles zero of our price array and we use the normalized double function to get six digits behind the dot and the calculated value should be stored in a variable that is called Adaptive Moving Average Value. And the last step is to create a chart output by using the comment function. It will output the text AMA value and the calculated value for the Adaptive Moving Average Value we have extracted here. Okay that’s it, now please click the Compile bottom and you should get no errors and no warnings here so now you can click the button or hit the F4 key to go back to MetaTrader. And in MetaTrader you want to click on View, Strategy Tester, and in the Strategy Test panel you want to select the Simple Adaptive Moving Average.ex5 file. Select any currency pair you like and please make sure to enable the check mark for the visualisation option before you start your test. And here we go! if you move your mouse to the current value here, you’ll see that we have a value of 1.544031, that’s exactly what we have calculated here. And in your Expert Advisor you would now compare the value of the adaptive moving average to the current price. And if the price is above the moving average you would buy, and if the price is below the moving average you would sell. Okay now you can create an Expert Advisor that uses the Adaptive Moving Average Indicator to find out if you want to buy or if you

    • 6 Min.
    • video
    MQL5 Tutorial – Simple Force Index Trading Robot

    MQL5 Tutorial – Simple Force Index Trading Robot

    Okay this time we are talking about the Force Index Indicator. It is a very simple indicator. It’s easy to read and also easy to code. If the indicator crosses the line in the middle from below and stays above the line, that could mean that we are bullish. And when it crosses the line from above and stays below the line like in this case, we have a bearish trend and we would like to sell. According to the website www.traderhq.com, this is also an indicator that was developed by Dr Alexander Elder, the author of the book: Trading for a Living. Okay now that we know how it works how can we create an Expert Advisor to use the indicator? The first step is to click the little button over here or hit the F4 key on your keyboard. That will start the Meter Editor and we want to click on File, New, Expert Advisor from template, Continue. We will call it Simple Force Index Robot. Now click on Continue, Continue, Finish, and delete everything above the Ontick function. These two comment lines are also no longer needed, because here we want to create an array, it shall holds several prices so it’s a double array and I will call it my price array. And now it’s time to define the Force Index definition by using the iForce function that is built-in into MQL 5. It takes some parameters, the first one is the current symbol on the chart, the second one is the period you have selected on your chart. The Force Index is calculated based on the last thirteen candles. You will also see it here in this little brackets. It is using the MODE_SMA that stands for Simple Moving Average and we want to use Tick volume. If you insert the indicator by clicking on Insert indicators, Oscillators, Force Index, you will see the exact same values here: thirteen candles, simple moving average based on the tick volume. Okay, let’s use the array set as series function that will sort the price array from the current candle downwards and now we use Copy Buffer for the Force Index definition we have created here. We need one line for the indicator that’s a zero here and we want to fill our array from the current candle that’s candle zero, for three candles that’s the three and store the result in our price array. And from our price array we are now going to extract the Force Index value for the current candle zero and we will use normalize double for six digits to get the six digits behind the point. And now we want to create a chart outputs depending on the value and if our Force Index value is above zero, we want to output the comment “trending upwards” directly on our chart and in the other case if the Force Index value is below zero, we want to have the text “trending downwards” on our chart. Okay, now please click on the little Compile button here or press the F7 key on your keyboard. That should compile your Expert Advisor without any errors or warnings here. And if that was going well please click on the button here or press F4 to go back to MetaTrader. Now in MetaTrader you want to click on View, Strategy Tester or press control and R. And in the Strategy Tester you want to select the Simple Force Index Robot.ex5 file. Let’s pick a currency pair here, enable the visualisation mode and click on Start and here we go. Now the indicator is below the line so it says trending downwards and as soon as the little indicator crosses the line from below, that changes to trending upwards. Okay, now you know how to create an Expert Advisor for Meta Trader5 that is using the Force Index Indicator and you have created it yourself in five minutes with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below How to create a force Index EA with MQL5 How to create a Bulls Power EA with MQL5 How to create a Demarker Expert Advisor with MQL5 How to create a MacD EA with MQL5 MQL5 TUTORIAL - PLATIN SYSTEM - VARIABLE INDEX… The post MQL5 Tutorial – Simple Force Index Trading Robot appeared first on MQL5 Tutorial.

    • 5 Min.
    • video
    MQL5 TUTORIAL – SIMPLE CUSTOM TIME FUNCTION

    MQL5 TUTORIAL – SIMPLE CUSTOM TIME FUNCTION

    In this video we are going to talk about a simple custom time function that we have created in MQL5. You see the output here on the chart, we have the date and we have the time including the seconds that is the local time that has been traded right here in the Strategy Tester and now we are going to find out how we can do a custom time function that is going to return the time and this readable format and to do that please click on the little button here or press F4 on your keyboard. Now you should see the Metaeditor and here you want to click on: “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file: “SimpleCustomTimeFunction”, click on “Continue”, “Continue” and “Finish” and now you can delete everything above the “OnTick” function and the two comment lines here. Okay, that’s it. First we need to create a string variable for our custom time that will be called: “myTime” and it’s of the type string, so it can contain text and to calculate it we just want to call a custom function called: “GetTime” to calculate the time, so the value of “myTime” will be calculated in the function “GetTime” and when we click on the “Compile” button right now we will see that the “GetTime” function is not defined, so that’s what we are going to do now. To create a custom function you can use a return type, in our case we will use the string return type, because we are going to deliver the time as text. The name of the function is: “GetTime” as we are calling it here and we don’t have any parameters so let’s add two brackets here, we use a local string that will be called: time with seconds (TimeWithSeconds). Now we create a string for the time with seconds (TimeWithSeconds) that’s also a string type variable and the name will be: “TimeWithSeconds”. Here comes the interesting part; we calculate the time with seconds (TimeWithSeconds) for the local time and that is done by using “TIME_LOCAL”. If you mark “TIME_LOCAL” and press the F1 key you will see that it returns the local time of a computer where the client terminal is running, but it’s a datetime variable so we use “TimeToStr” to change it to a text and the function: “TimeToStr” (time to string) is converting a value containing time in seconds since the 1st of January in 1970 into a string in this format. We use “TIME_DATE” that will give us the year, the month and the day – that’s the first part here, this is the pipe sign, it separates the first from the second parameter, the second parameter is “TIME_SECONDS” and that will deliver us the local time including the seconds. Okay. In the last step we want to return the calculated time to the main function by using the “return” function for “TimeWithSeconds” so it will return the calculated value here and assign it to “myTime” and to see it on the chart we use the “Comment” function to create a chart output for the time and when you are done you can click on the “Compile” button here, that should work without any errors now and if that is the case you can click on the little button here to go back to Metatrader. In Metatrader you want to click on “View/ Strategy Tester” or press CTRL and R and now you should see the Strategy Tester here, please select the “SimpleCustomTimeFunction.ex5”, mark the visualization option here and start your test. We have the date and the time directly on the Forex Chart and now you know how to create an Expert Advisor to calculate the formatted time output on your chart and you have done it with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 126 SIMPLE RUNNING TIMER MQL5 Tutorial - Calculating Time Difference in… MQL5 TUTORIAL BASICS - 124 SIMPLE ORDER CLOSE TIME MQL5 Tutorial - Advanced Library Expert Advisor MQL5 TUTORIAL - SIMPLE MOUSE CLICK EVENT The post MQL5 TUTORIAL – SIMP

    • 5 Min.

Top‑Podcasts in Wirtschaft

Handelsblatt Morning Briefing - News aus Wirtschaft, Politik und Finanzen
Teresa Stiens, Christian Rickens und die Handelsblatt Redaktion, Handelsblatt
Alles auf Aktien – Die täglichen Finanzen-News
WELT
Finanzfluss Podcast
Finanzfluss
Kampf der Unternehmen
Wondery
OHNE AKTIEN WIRD SCHWER - Tägliche Börsen-News
Noah Leidinger, OMR
OMR Podcast
Philipp Westermeyer - OMR