MQL5 Tutorial

Follow MQL5 Tutorial
Share on
Copy link to clipboard

With MQL5 and Metatrader5 you can start algorithmic trading today. The builtin Metaeditor for Expert Advisor Programming and the MQL5 programming language can help you to trade 24/7 with your own automated trading robot on up to 22 forex charts - without harming your trading plan or loosing trading…

MQL5 Tutorial


    • Dec 15, 2024 LATEST EPISODE
    • monthly NEW EPISODES
    • 6m AVG DURATION
    • 237 EPISODES


    Search for episodes from MQL5 Tutorial with a specific topic:

    Latest episodes from MQL5 Tutorial

    MQL5 Tutorial – How to simply adjust user input with MQL5

    Play Episode Listen Later Dec 15, 2024 1:51


      Introduction to Enhancing a Simple Expert Advisor (00:00 – 00:07) Introduction to improving a simple expert advisor by allowing user adjustments, following the results of a year-long test. Reviewing the Year-Long Test Results (00:07 – 00:19) Overview of the test results: 73 trades made, with 54 short trades and 19 long trades, and the lack of adjustable inputs. Enabling User Adjustments for Lot Size (00:19 – 00:30) The goal to enable users to adjust the lot size of trades, which is currently hard-coded in the source code. Modifying the Expert Advisor to Include Input Variables (00:30 – 00:43) Steps to modify the expert advisor to include input variables, specifically for adjusting the lot size. Creating a Dynamic Input Variable for Lot Size (00:43 – 00:56) Instructions on creating a dynamic input variable for lot size, allowing it to be changed by the user. Replacing Fixed Lot Size with the New Variable (00:56 – 01:03) Replacing the fixed lot size in the code with the new variable and saving the changes. Compiling the Code and Testing the New Feature (01:03 – 01:17) Compiling the updated code and testing the new feature in Metatrader, with visualization enabled. Observing the Adjustable Lot Size in Action (01:17 – 01:28) Observing the first trade with the new adjustable lot size and stopping the test to change the input. Changing the Lot Size and Testing Again (01:28 – 01:43) Adjusting the lot size to a different value and testing again to demonstrate the flexibility of the new input feature.   In one of our other videos we have created a simple buy trade system and this is the result of a whole year. It made seventy three trades, fifty four were short trades and nineteen were long trades. You see under the input tab we have absolutely no values here so we cannot set anything that is not hardcoded in our source code. Now we want the user to be able to adjust the Lot Size of a trade here, to do that we simply click on Simple Buy Trade and click Modify. This is how our short E.A. looks like and this is the Lot Size. To create a dynamic value that can be changed by the user you have to make it an input variable and will be a double variable, and we will call it MyLotSize. Let’s assign ten Micro Lot here, copy the name and exchange the fixed ten Micro Lot Size here with our new variable. I will save it as Simple Buy Trade with input. Let’s compile the code and hit F4 to bring up the Meta Trader. I will select the system here, check the visualization option and start the test. This is our first trade and its ten Micro Lot. Let’s stop the test, go to inputs and change it to 0.2, now it is 20 Micro Lot. If you make something adjustable by the user, you can do it by making it an input. Afterwards the value can be simply changed without recompiling the code. The post MQL5 Tutorial – How to simply adjust user input with MQL5 appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Commodity Channel Index

    Play Episode Listen Later Dec 8, 2024 5:16


    With MQL5 for Metatrader5 we can use the ICCI function that is built in to create an Expert Advisor that will use the Commodity Channel Index Indicator to create entry signals on our Forex Trading Chart… This video is about the commodity channel index. The commodity channel index is an oscillator and it will tell you if something is overbought or oversold. This is one of the oscillators I like because it is very easy to understand. It has one hundred plus and a one hundred minus line here and whenever the value rises above the upper line, it’s overbought. In the other case if the indicator falls below the lower line, it’s oversold. The commodity channel index can be created with the MQL 5 function ICCI that is built-in into MQL 5. And now we want to create a little Expert Advisor that will tell us when the market is overbought or oversold. To do that please click the little button here or hit the F4 key on your keyboard. That will bring up the Meta Editor, and here we want to select File, New, Expert Advisor from template, continue. And we will call the Expert Advisor Simple Commodity Channel Index. Now click on Continue, Continue, Finish, everything above the Ontick function can be removed and we will also delete the two comment lines here and we will start by creating a little array for our prices. It's a double array and we will call it my price array. And for the definition of our commodity channel index, we will use the ICCI function of MQL 5. For the current symbol on the chart and the selected period, this might be Euro/U.S. dollar and this might be the minute chart or the hourly chart, and the calculation is done for fourteen candles, because this is the default value of the commodity channel index when you drag it on your chart by using Insert, Indicators, Oscillators, commodity channel index. And it is calculated based on the close prices. In the next step we need to sort the price array from the current candle downwards by using the function arraysetasseries for the price we have created here. And now we use copy buffer for the CCI definition from line here. This is for the first line, it is line zero. And for the current candle that’s candle zero, and we need the values for three candles, that’s the three here, and we want to store the results in my price array. We want to get the CCI value of the current candle in our price array. Okay now we need the chart output depending on the value so if our value is above the upper line we want to put the text “Overbought” on our chart by using the comment function. And if it’s below the lower line we want to output the text “Oversold.” And when it’s between the lines we just use an empty output because we have no signal. Okay that’s it. If you’re ready, please click on the little compile button here or hit the F7 key on your keyboard. That should compile your Expert Advisor without any error or warnings. And in that case we want to bring up the MetaTrader by pressing the F4 key or hitting the little button over here. In Metatrader please click on View, Strategy Tester or hit control and R. That should show you the strategy tester panel, and here we want to select the simple commodity channel index.ex5 file. Please make sure to mark the visualisation option here and click on start. And here is our Expert Advisor at work. Now it’s below the lower line and then it says oversold and when it’s above the upper line it says overbought. Okay, now you know how you can use the Commodity Channel Index Indicator to create entry signals in your own Expert Advisor. And you have done it yourself with a few lines of MQL 5 code. The post MQL5 Tutorial – Simple Commodity Channel Index appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE ICCI EXPERT ADVISOR

    Play Episode Listen Later Feb 18, 2024 5:48


    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 creates outputs for buy and sell signals on your chart and now you know how you can code it and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL- SIMPLE ICCI STANDALONE EA How to create an ICCI Expert Advisor with MQL5 How to create a commodity channel index EA with MQL5 MQL5 Tutorial - How To Code A Simple Commodity Channel Index MQL5 TUTORIAL - SIMPLE STOCHASTIC STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE ICCI EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Adaptive Moving Average Robot

    Play Episode Listen Later Feb 11, 2024 6:13


    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 want to sell and you have created it in less than five minutes with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below How to create an Adaptive moving Average EA with MQL5 The Empowering MQL5 Moving Average MQL5 TUTORIAL - PLATIN SYSTEM - ADVANCED MOVING… MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - HOW TO CREATE A SHIFTED MOVING AVERAGE The post MQL5 Tutorial – Simple Adaptive Moving Average Robot appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Force Index Trading Robot

    Play Episode Listen Later Feb 3, 2024 5:27


    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.

    MQL5 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – LIVE UPDATES AND A LIVE PROFIT DOCUMENTED

    Play Episode Listen Later Jan 10, 2024 5:51


      20240101: DOWNLOAD 28 result videos for this system https://bit.ly/41OIpzK 20240101: README Documentation (updated often): https://bit.ly/41FPceY 20240102: System Download for Demo accounts: https://bit.ly/3H3diqt 20240103: Account Setup: https://youtu.be/qtCXQI3XL_4 20240104: Trading System Import: https://youtu.be/4AWpxGKVS4A 20240105: First Account Profit: https://youtu.be/BqXaoGyy3QU 20240106: Setup MX Linux server in 5 minutes: https://youtu.be/JVZoYn2w6Yw 20240107: Setup Metatrader on Linux in 3 minutes: https://youtu.be/DTkOQKW3HT4 20240109: Live Updates & Live Profit: https://youtu.be/BCnttK7d4HI In this video, I want to talk about how I got my advanced statistics to run. Actually, I had to change the account to Robo Forex and use a demo account there because what I didn’t know was that FXblue is not able to provide statistics for MetaQuotes demo accounts because they simply do not have the MetaQuotes company in their list. So when you pick a broker, you need to pick one that’s in their list, and MetaQuotes is not part of that. Yes, I could write to the support to add MetaQuotes, but I guess for this experiment, it’s more useful to use an account that actually is included. And for Robo Forex, they support demo accounts. I have to admit that advanced statistics for Robo Forex have been a pretty standard for me and my clients in the last few years. If you don’t know, I’m offering a premium course about MQL5 programming, and that is also where a lot of people use the same Robo Forex account settings that I use. So I actually didn’t know that MetaQuotes wasn’t in the brokers list. And I switched to this account, and that means that we had to start over with $100,000. So right now, we have made a profit of $71, and I guess in the next hour or so, we will make a few more trades. But the crazy thing is, I actually tried to use this account sync option. They say that it works for MetaTrader 4 and MetaTrader 5, but it wasn’t running on Linux and it wasn’t performing. So I thought, okay, I need to download this publisher app here, and I did. So the version I picked was this one for MetaTrader 5. You can download it for free and you will get a zip file. And when you open that zip file with Linux, you will find there is a publisher ex5 file inside. I had to extract that. Now, let’s go back to the trading terminal and click on File, Open Data folder, MQL5 experts. And here is that FX Blue publisher ex5 file. I then opened a new chart, and here is the ExpertAdvisor that you can drag onto the chart. I’m not going to replace it right now because it’s already working. You can see that the last synchronization was today at about 20 minutes past 5. Let’s open the FX Blue statement. This is the correct account number. It says that we have a history of eight days, which is true because the account is eight days old, but I started to use it yesterday. I can now refresh the state, and it says we have an open loss of $23 and a profit of $71. So let’s go back to MetaTrader and check. Yes, that’s about what is happening right now. And you can see that we have a profit here. So I expect my system to close both trades in the next few minutes because it’s configured in a way that when a new candle appears on the chart and the profit is higher than what I have defined, it should close both trades and lock in the account-based profit. This is the current candle. Currently, I’m using the hourly candles, so let’s switch to one minute. And I think that it will only take a few seconds until we see that this trade is closed, at least until the profit value drops. But with the lot size of 0.86 lots, it’s just a question of a few seconds before the profit value is reached again. Here is the new candle, but the profit is below $10, so let’s wait for the next one. And here we are. We have closed closed the trade. Now, let’s go back to the hourly chart. It already opened a new one. Now, the balance is $100,101. The history has changed. And when we go back to the stats here, we still see $71 of profit. But when we refresh the page, here is the new state, and this matches the account data. And as soon as this trade is going to be in the profit range, we will see another update. Currently, I’m experimenting with the take profit value here. I can change that in the source code as I do for my clients. Now you know how to activate the FX Blue publisher file, do automated status updates for FX Blue. So that’s it for today’s video. I say thank you for watching, and I will see you in the next one.. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - LIVE TRADING EXPERIMENT 2024 -… MQL5 TUTORIAL - LIVE TRADING EXPERIMENT 2024 - SETUP… MQL5 TUTORIAL - JOIN THE GREAT TRADING EXPERIMENT 2024 MQL5 TUTORIAL - LIVE TRADING EXPERIMENT 2024 -… MQL5 TUTORIAL ENGLISH - SETUP YOUR ADVANCED STATISTICS The post MQL5 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – LIVE UPDATES AND A LIVE PROFIT DOCUMENTED appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – SYSTEM DOWNLOAD AVAILABLE (below)

    Play Episode Listen Later Jan 3, 2024


      20240101: DOWNLOAD 28 result videos for this system https://bit.ly/41OIpzK 20240101: README Documentation (updated often): https://bit.ly/41FPceY 20240102: System Download for Demo accounts: https://bit.ly/3H3diqt   Okay, let’s start from the beginning. The trading experiment we’re conducting in 2024 is different from anything I’ve done before. A few weeks ago, I was pretty sick and was lying in bed, watching movies on Netflix all day. These included movies with commercials, and one ad I kept being shown was about a woman getting face cream for Christmas. She also demonstrated how to use the cream with pineapple to improve her skin. This didn’t interest me at all, and even if I was shown this ad a thousand times, I would never use face cream with pineapple.   Why am I telling you this? It’s about relevance! If I offer something that is irrelevant, nobody will want to buy it. It’s the same with pineapple face cream. It doesn’t matter how hard I try to convince someone if it’s just not relevant. I don’t think it matters what advertising technology is used. If something doesn’t interest me, there’s little anyone can do about it, no matter how appealing the advertising is. As a rule, I look for solutions that bring me more benefit than cost – popularly known as a bargain. In other words, you get something of value for less than you would be prepared to pay. That’s why we’re doing something different this year. I think a lot of companies are at an impasse right now because they’re trying to convince everyone on the planet to buy their products and everyone is trying to get louder and louder. I myself am not a fan of being ripped off and have never made a big show of how and what I do in trading.   I know that many people in this field wave big wads of cash from a skyscraper in Dubai or loll around on their Ferrari, but I believe that most potential clients quickly see through such dubious strategies. So I spent a long time looking for a way to offer something that I would buy myself, in an unobtrusive way that could convince people like me. I found Frank Kern, who teaches a strategy that I really like. It is described as the oldest trick in his books and is about really helping someone to convince them that you can help them. When it comes to automated trading, that’s pretty easy and that’s why we’re using a demo account now and will be trading with a demo system to get better results in 2024. I believe that you are interested in better results, and I know from the last ten years that 10 to 15 percent of the people who watch these videos are interested in buying the right solution. That doesn’t mean you have to buy it yourself, but I believe that probabilities are the key to success.   Knowing my numbers, it is very likely that 10 to 15 percent of viewers will spend money with me later because they are convinced that what I am offering is exactly the solution they were looking for. That’s why the Robot Trading System is now available as a free download for demo accounts. You can find the link below this video. In the next videos we will look at how to set up this system in Meta Trader to achieve good results in the long term. Anyway, I believe that you should trade the first weeks or months on a demo account, and after that you can use the system on a so-called cent account. So this strategy fits well. And I think it can help you and me to achieve better results in 2024. Okay, that’s it for this video. I’ll see you in the next one, and thank you for watching. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - JOIN THE GREAT TRADING EXPERIMENT 2024 MQL5TUTORIAL - HOW TO GET ADVANCED STATISTICS FOR 3… MQL5 TUTORIAL - FREE TRADING TRAINING FOR 2023 MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM LEARN MQL5 TUTORIAL BASICS - LEVEL 1A BUILD YOUR OWN… The post MQL5 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – SYSTEM DOWNLOAD AVAILABLE (below) appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – JOIN THE GREAT TRADING EXPERIMENT 2024

    Play Episode Listen Later Jan 2, 2024


        20240101: DOWNLOAD 28 result videos for this system https://bit.ly/41OIpzK 20240101: README Documentation (updated often): https://bit.ly/41FPceY 20240102: System Download for Demo accounts: https://bit.ly/3H3diqt   This video is about a big trading experiment that I would like to do together with you. Today is January 1, 2024, it’s just before 4 pm and I’ve spent the day today running strategy tests for all the major currency pairs that I trade myself for this system here, trading through the entire year of 2023. And I will also make these videos available for you to watch for yourself. But the big experiment here is that I would like to use the year 2024 together with people like you to make this system better. That’s why I’m now offering a version of the Robot Trading System that runs indefinitely on a demo account from January 2024. This means that if you use a demo account, you can do everything that I do myself. I will also initially trade this system on a demo account, and it will be about how you can set up, adjust and improve such a system over the course of the year so that you get a decent result at the end of the year. We will also discuss and share some other things that might help you, even if you haven’t had anything to do with automated trading before or if you want to have a look at the whole thing first if you are interested in joining in. You don’t need any prior knowledge, you don’t need any capital. All you need is a computer that has been manufactured in the last ten years. You need a demo account. You can get that for free from Metaquotes or other companies and you need to do strategy tests like this here with Metatrader five, which you can also download for free. This time we would have made a net profit of €1,642 on an account with a deposit of €10,000. And why are we doing all this on a demo account? Well, there are few people who are actually willing and ready to invest time in real trading results on a demo account before trading real money with a real money account. And in almost every trading session there are always dips like this. And that leads people to close their account at exactly this point. Because that’s where the fear is greatest. But you don’t have to be afraid on a demo account. And as soon as you feel that the system works well enough for you, you can switch at any time. But we have already done experiments like this in the past and I would like to start 2024 in the same way. Because I believe that nothing can replace the knowledge you have gained yourself. And in this case, I think you have little to lose and a lot to gain. That’s it for this opening video. I wish you a happy new year and in the next few days you will receive more information, new videos and also the download link to the version of this system that you can then use for free on your own demo account. If you are already an existing customer, I have activated a few more parameters for the Robot Trading System here. This means that the system can now be controlled more precisely. And if you like the results here, I’ll see you in the next video. Thank you very much for watching. And we’ll continue in the next video. ​ Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - LIVE TRADING EXPERIMENT 2024 -… MQL5 TUTORIAL - FREE TRADING TRAINING FOR 2023 LEARN MQL5 TUTORIAL BASICS - LEVEL 1A BUILD YOUR OWN… MQL5 TUTORIAL - 101 WHAT HARDWARE FOR ALGORITHMIC TRADING MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM The post MQL5 TUTORIAL – JOIN THE GREAT TRADING EXPERIMENT 2024 appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple MQL5 New Candle Robot

    Play Episode Listen Later Dec 29, 2023 4:52


      Introduction to Counting New Candles on the Chart (00:00 – 00:17) Discussing the usefulness of counting new candles on a chart and showing the output of four candles since the start of the expert advisor. Importance of Candle Counting in Automated Trading (00:17 – 00:36) Explaining why counting candles is important in automated trading, especially when trading multiple positions and currency pairs. Resource Management and Avoiding Computer Crashes (00:36 – 01:17) Highlighting the importance of resource management to avoid computer crashes, especially during fast market movements. Creating a Simple Expert Advisor for New Candle Detection (01:17 – 01:57) Demonstrating how to create a simple expert advisor in MetaTrader to detect new candles. Setting Up Price Array and Sorting for Candle Data (01:57 – 02:20) Instructions on setting up a price array and sorting it to hold price data for candle detection. Filling the Array with Price Data and Counting New Candles (02:20 – 02:59) Steps to fill the array with price data and use it to count the number of new candles since the last start of the expert advisor. Creating Timestamp Variables for Candle Time Tracking (02:59 – 03:42) Creating date/time variables to track the timestamp of the current and last checked candles. Updating Candle Counter and Displaying Output on Chart (03:42 – 04:36) Updating the candle counter when a new candle is detected and displaying the output on the chart.   Sometimes it is helpful to count the new candles on the chart. The output in the left upper corner on the chart says we had four candles since we started this Expert Advisor,. One, two, three, four, this is the fifth one. Now you might ask yourself why is this important? Well an Expert Advisor can trade several positions on a chart, and you also can trade several currency pairs and every single candle on the chart can have lots of different price moves. And every time a price changes the OnTick function will be triggered but a lot of trading strategies use close prices. So instead of maybe fifteen calculations within this candle, you would only need one calculation for the close price. Even a high tech computer may have a resource problem, if you try to calculate several dozen trades on several dozen charts because when the market starts to move really fast your computer might be overwhelmed and it may cause a crash. So if you want to avoid computer crashes, it’s a good idea to save resources. To do that you can simply check if a new candle is created and now we will create a simple little Expert Advisor to do that. So let’s click the little button over here or hit the F4 key to bring up the Meta Editor. Select File, new Expert Advisor from template, continue, and we will give it the name Simple New Candle. Now click on continue, continue, finish, and remove everything above the OnTick function. Let’s delete the two comment lines here. Okay now the first thing we need is the price array to hold our price data. So let’s create that, that can be done with MQLRates and we will call a price data. Now we want to sort our array from the current candle downwards with arraysetasseries and in the next step we need to fill it with data. That is done by using copyrates for the current currency pair on the chart and the current selected period. For example I prefer a one minute charts, we want to start with the current candle zero, and copy the price for three candles into our little array price data. To count the number of new candles since the last start of the Expert Advisor, we need a new candle counter. This candle counter will be an integer and it will be static, that means it will never lose its value even if we would like to leave the function. Okay let’s move on, now we are creating datetime variable that will hold a time stamp; this one will hold the time stamp for the last time we checked and it is also static so it will never lose its value. And for the current candle we need another datetime variable and that will be called time stamp current candle and we will fill it by getting the time value of the current candle from our price data array. And if the time stamp for the current candle is different from the timestamp the last time we checked, we want to remember the current timestamp for the next time by assigning it to the timestamp last check variable. Now we want to add the value one to our current candle counter and the last thing we need us the output on the chart. So let’s compile the little Expert Advisor here and we have zero errors and zero warnings. So let’s hit the F4 key or click this button to go back to MetaTrader, select View Strategy Test or hit the control and the R key. Look out for the simple new candle.ex5 file. Mark the visualization option and click on start. And now you should see your candles on the chart being counted and that can be done very fast and you did it in five minutes by creating this little Expert Advisor here. Not sure what to do? Click on the automated trading assistant below How to find new chart candles with MQL5 How to create a Simple Moving Average Expert Advisor… MQL5 TUTORIAL - HOW TO STILL BENEFIT WHEN THE PRICE… MQL5 TUTORIAL - BEWARE OF HISTORY QUALITY ISSUES MQL5 TUTORIAL - 131 STANDALONE EMA MACD EXPERT ADVISOR The post MQL5 Tutorial – Simple MQL5 New Candle Robot appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple MQL5 Bollinger Bands Robot

    Play Episode Listen Later Dec 19, 2023 5:56


      Introduction to Bollinger Bands and Expert Advisor Calculation (00:00 – 01:03) Introduction to using Bollinger Bands in trading and how the expert advisor can calculate all three bands with higher accuracy. Trading Strategy with Bollinger Bands (01:03 – 01:34) Explaining the trading strategy: opening a short trade when the price breaks the upper Bollinger Band and a long trade when it breaks the lower band and returns. Creating an Expert Advisor for Bollinger Bands (01:34 – 02:05) Instructions on creating an expert advisor in MetaTrader to automate trading with Bollinger Bands. Setting Up Arrays and Defining Bollinger Bands in Code (02:05 – 03:21) Coding steps to set up arrays for each Bollinger Band and defining the bands based on the current chart and time period. Outputting Calculated Values on the Chart (03:21 – 03:38) Using the comment function to output the calculated values of the Bollinger Bands on the chart. Compiling the Code and Preparing MetaTrader (03:38 – 04:20) Compiling the expert advisor code and setting up MetaTrader to display the Bollinger Bands on the chart. Testing the Expert Advisor in Strategy Tester (04:20 – 05:39) Running the expert advisor in the strategy tester and comparing the calculated values with the chart’s Bollinger Bands.   If you like to use indicators, you might have heard of the Bollinger bands. This little Expert Advisor here can calculate all three bands. If you put your mouse cursor over the middle band here you see a value of 0.712078 and our calculated value for the middle band is 0.7120775, this calculation even is a little bit more accurate. The value for the upper Bollinger band is 0.712457 and here we have 0.712457. And for the lower Ballinger band it’s the same 0711698, 0.7116979. This value is even more accurate because this one is rounded. So what can we do with a Bollinger Bands? Well the idea is as the price breaks the upper Bollinger band we want to get in at the next entry and we would like to open a short trade here, because we expect the price to fall. In the other case if the price breaks the Bollinger band here and it gets back into the bands we would go for a long trade because the price might rise. So if you can create an automated Expert Advisor that is able to compare these values over here with the current price, you can fully automate this. Your computer can trade the Bollinger bands automatically and you don’t have to sit in front of your screen all the time. So let’s create a little Expert Advisor! To do that please hit the F4 key or click this little button over here and that will open the Meta Editor. Here we click on new Expert Advisor from template, continue, we will call it simple Bollinger bands, click on continue, continue, finish. Remove everything above the OnTick function, remove the comments and the first thing we need is an array for each of the Bollinger bands one, two, three times a double array. Now we need to sort our three arrays to hold prices from the current candle downwards and we do that with the function arraysetasseries. In the next step we need to define the Bollinger bands. We want our Expert Advisor to use the current chart for the current time period used on the chart. It should calculate the Bollinger bands for twenty candles without any shift and with a standard deviation of two, that all should be calculated for the closed price of the candle. Afterwards we need to copy the price information into three arrays and now it’s time to calculate the actual value for the current candle and to store it in a variable for each of the three bands. That’s it for the calculation. Now we want to output our calculated values on the chart, we do that with the comment function and it will output the name of the variable and the value we have calculated in this block. Okay let’s compile the code. We have no errors and no warnings. So let’s click the little button over here or hit the F4 key to bring up the Meta Trader, to make the Bollinger band visible on the screen we will use a little trick. Please click on insert, indicators, Bollinger bands, select the period of twenty candles with a shift value of zero and the deviation value of two, we want to apply all this to the closed price of the candles and now you can pick a color and style for the line. I prefer these thicker lines. Let’s click on okay and you will see the visual representation of the Bollinger bands on the chart. Now right click the chart select templates, save template and save it as Tester.tpl to make it the default chart for strategy tester. And if you save it as default.tpl it will also become the default template if you open a new chart in life trading. So let’s bring up the Strategy Tester by clicking on View Strategy Tester or hitting the control and the R key and select the simple Bollinger bands.ex5 file, make sure to and enable visualization here and start the test. And this is what you should see now, let’s stop it here and check the values. This is 0.706251, 0.7062505, thats okay. The upper Bollinger band is 0.706916, 0.706916, that’s also okay and the lower Bollinger band is 0.705585, and that’s exactly what’s calculated here, so it works. In this video you learned to calculate all the Bollinger bands by creating this little Expert Advisor here. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - HOW TO CREATE THE BOLLINGER BANDS… MQL5 TUTORIAL - PLATIN SYSTEM - BOLLINGER BANDS ENTRY SIGNAL How to create an advanced Bollinger Bands entry How to create a Bollinger Bands Expert Advisor with MQL5 MQL5 TUTORIAL BASICS - 129 SIMPLE BOLLINGER BANDS… The post MQL5 Tutorial – Simple MQL5 Bollinger Bands Robot appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Chart Objects

    Play Episode Listen Later Nov 23, 2023 6:37


      Introduction to Creating Simple Chart Objects in MQL5 (00:00 – 00:34) Introduction to the tutorial on creating simple objects like arrows on the chart each time a tick comes in, using MQL5. Opening MetaEditor and Creating a New File (00:34 – 01:05) Instructions on opening MetaEditor, creating a new Expert Advisor file named “Simple Chart Objects”. Setting Up the Code Structure and Creating Price Array (01:05 – 01:39) Deleting unnecessary code and creating an array for price information using MQL rates. Sorting the Array and Filling with Price Data (01:39 – 01:52) Sorting the array downwards and filling it with price information for the current chart and period. Creating a Static Counter and Drawing Arrows (01:52 – 02:25) Creating a static counter and using it to draw arrows on the chart with ‘ObjectCreate’. Configuring the Arrow’s Appearance and Position (02:25 – 03:08) Setting the arrow’s type, color, and width, and positioning it at the highest point of the current candle. Changing Arrow Appearance with Counter Value (03:08 – 03:42) Changing the arrow’s appearance based on the value of the static counter. Setting Arrow Color and Size (03:42 – 04:23) Configuring the arrow’s color to green and increasing its size. Moving the Arrow and Displaying Counter Value (04:23 – 04:57) Moving the arrow to the highest price of the current candle and displaying the counter value on the chart. Incrementing the Counter for New Symbols (04:57 – 05:17) Increasing the counter by one for each new tick, resulting in different symbols on the chart. Compiling the Code and Testing in MetaTrader (05:17 – 05:51) Compiling the code and testing the Expert Advisor in MetaTrader using the Strategy Tester. Observing Dynamic Symbols on the Chart (05:51 – 06:11) Watching the changing symbols on the chart during the test and understanding how to print dynamic symbols using MQL5.   This time we are going to create simple objects. Each time a tick comes in, one of these objects will be painted here. Usually you will see things like arrows up and down, but actually there are a lot of more possibilities for such an arrow symbol. Everything you see here is called an arrow even if it doesn’t look like one. Now how can we create an Expert Advisor in MQL5 that is going to draw objects like these? To do that, please click on the little button here or press the F4 key on your keyboard. And that will bring up your MetaEditor window and here you want to select File, New, Expert Advisor from Template, Continue. I will call it SimpleChartObjects here, Continue, Continue and finish. And now you can delete everything above the OnTick function and the two comment lines here. And first we need an array for prices, we can create one by using MQLrates and it will have the name Price Information, now we are going to sort the array downwards from the current candle by using arraysetasseries and by using copyrates we are going to fill the price information array for the current chart and the period selected on the chart from the current candle zero for all the bars on the chart and store the values in our array. And now we are going to create a static counter, it will be an integer with the name i, and we will use that value to actually create an arrow with the name MyArrow. Please remember in MQL 5 an arrow can look like a circle or a square or anything else. So we use ObjectCreate for the current chart and our object will have the name MyArrow and we use OBJ_Arrow to create it. The next parameter would be a sub window; we will use a zero here because we are going to create the arrow here in the main window. You might have seen indicators that use a sub window below. We will use the current time and the arrow should be placed on the highest point of the current candle in our price information array we have created here. And with object set integer for the current chart, and the object, my arrow, we use OB J Prop_Arrow Code, and the value of the static counter to change how our object looks. Currently we have the value 179 and as soon as that changes to 180 the arrow code changes and so does the way our arrow looks. And for 181 our arrow would look like this; let’s select a color here, that is done by using objects set integer for the current chart for the object with the name My Arrow and we use OBJ_Prop_Color and we would like to have the color green. If you press F1 on your keyboard you will see a lot of other colors that you can use. To make our object a little bit bigger we’re using object set integer for the current chart for the object with the name MyArrow and we use the OBJProp_Width to set the size to 20. And now we move the object by using ObjectMove for the current symbol and for the object with the name MyArrow on the main window we used, for the current time and we move it to the highest prize of the current candle. I would actually like to have a chart output for the current counter value so we use comment to output the text “i has the value” followed by the current value of the static integer variable i. And in the last step we are going to increase our counter by one, that is done with I++ and now the next time a tick comes in we should see another symbol on the chart. Okay that’s it; let's compile the code here and that worked without any errors. So please click on the little button here or press F4 on your keyboard to go back to MetaTrader. And in MetaTrader click on View, Strategy Tester or press control and R to bring Not sure what to do? Click on the automated trading assistant below How to create a chart object with MQL5 How to create a label object with MQL5 MQL5 TUTORIAL - SIMPLE ON BALANCE VOLUME How to create a line object in MQL5 MQL5 TUTORIAL - SIMPLE SHIFTED SMA EXPERT ADVISOR The post MQL5 Tutorial – Simple Chart Objects appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – HOW TO CREATE A SHIFTED MOVING AVERAGE

    Play Episode Listen Later Nov 10, 2023 2:45


      Introduction to Shifted Moving Average Indicator (00:00 – 00:11) Introduction to the concept of a shifted moving average, which projects one moving average into the future. Setting Up the MQL5 Code (00:11 – 00:18) Overview of the MQL5 code setup, including the creation of a string variable named ‘signal’ for storing trading signals. Declaring Moving Average Arrays (00:18 – 00:27) Declaring two arrays, ‘my moving average array’ and ‘my shifted average array,’ to store values of moving averages. Defining Two Moving Averages (00:27 – 00:46) Using the ‘IMA’ function to define two moving averages: a 50-period simple moving average and another 50-period SMA with a 20-period shift. Sorting Arrays and Copying Values (00:46 – 01:08) Sorting the arrays in descending order and using ‘CopyBuffer’ to copy the last three values of both moving averages into their respective arrays. Calculating Moving Average Values (01:08 – 01:15) Calculating and storing the values of the current candle for both moving averages. Generating Trading Signals (01:15 – 01:32) Generating buy or sell signals based on the comparison of the moving average values. Displaying Trading Signal on Chart (01:32 – 01:43) Using the ‘Comment’ function to display the current trading signal on the chart. Conclusion and Further Learning Resources (01:43 – 02:18) Concluding remarks on the functionality of the code and suggestions for further learning through other videos or a premium course.   In this video, we are going to take a look at this indicator here. It’s a shifted moving average, which means that we use one moving average and project the results into the future. Let’s see how we can do something like this with MQL5. In this MQL5 code, a string variable named signal is created to store the trading signal.   This signal will be either buy or sell. Two arrays, my moving average array and my shifted average array are declared. These arrays will store values of moving averages. Two moving averages are defined using the IMA function. Moving average definition calculates a 50-period simple moving average using the closing prices of the current symbol and period. Shifted average definition calculates another 50-period SMA, but with a 20-period shift applied. The array set as series function is used to sort the my moving average array and my shifted average array in descending order. The copy buffer function is used to copy the last three values of both moving averages into their respective arrays. The values of the current candle for both moving averages are calculated and stored in my moving average value and my shifted average value.   Trading signals are generated based on the comparison of these moving average values. If my moving average value is greater than my shifted average value, it sets signal to buy. If my moving average value is less than my shifted average value, it sets signal to sell. The current trading signal, buy or sell, is displayed on the chart using the comment function. This code calculates two moving averages, compares their values, and generates a buy or sell signal based on the comparison. It then displays the current trading signal on the trading chart for reference.   Okay, by now you should have a working version of this indicator on your chart. I hope everything went well. If it was too fast for you or if you have no idea what all the code does, you maybe want to watch one of the other videos or maybe even the premium course on our website might be interesting for you. For now, I say thank you for watching and I will see you in the next video. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - SIMPLE SHIFTED SMA EXPERT ADVISOR MQL5 Tutorial Classics - Simple Moving Average Robot… MQL5 TUTORIAL BASICS - 114 SIMPLE SHIFTED PRICE EA MQL5 TUTORIAL - SIMPLE SIGNAL STACKING How to create an Adaptive moving Average EA with MQL5 The post MQL5 TUTORIAL – HOW TO CREATE A SHIFTED MOVING AVERAGE appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – HOW TO TRAIN AND SCALE A WORKING REAL WORLD TRADING SYSTEM

    Play Episode Listen Later Oct 21, 2023 9:49


      Introduction to Real World Trading System (00:00 – 00:14) Introduction to the robot trading system used by the presenter. Overview of the system’s performance and purpose. Analyzing Trading System Performance (00:14 – 00:29) Detailed look at the trading system’s results and trades. Discussion on the balance and equity of the system. Understanding Trade Impact and Emotions (00:29 – 01:06) Exploring the emotional impact of trade results. Difference between small and large losses. Trade History Analysis (01:06 – 01:20) Examination of the system’s trade history, including profits and losses. System Strategy and Position Series (01:20 – 01:39) Description of the trading strategy using position series. Explanation of closing positions at once. Decision Making in Trading (01:39 – 02:14) Criteria for deciding between single or multiple positions. Rules-based approach to trading decisions. Trend Analysis with Moving Averages (02:14 – 02:31) Using simple moving averages to identify market trends. Explanation of downtrend indicators. Trading With and Against Trends (02:31 – 02:58) Strategies for trading with the trend and handling corrections. Examples of trades that didn’t work out and why. Analyzing Correction Phases and Trends (02:58 – 03:29) Understanding correction phases in stable trends. Strategies for closing positions profitably. Future Decision Making in Trading (03:29 – 03:47) Challenges in predicting future market movements. Importance of decision making in trading. Using FXBlue for Detailed Statistics (03:47 – 04:17) Utilizing FXBlue for better trading statistics. Accessing detailed system performance data. System Performance and Statistics Overview (04:17 – 04:53) Comprehensive review of the trading system’s performance. Analysis of winners, losers, and total trades. Trade Analysis and Currency Focus (04:53 – 05:10) Breakdown of trade types and currency pairs used. Emphasis on trading in a downtrend. Scaling Up the Trading System (05:10 – 05:28) Considering increasing the trading volume. Evaluating the system’s readiness for scaling. Average Trade Duration and Profitability (05:28 – 06:05) Analysis of average trade duration and profitability. Importance of balancing profitable trades with losses. Understanding Trading Costs and Spreads (06:05 – 06:36) Discussion on swap fees and spread costs in trading. Impact of broker charges on trading profitability. Market Trend Analysis and Moving Averages (06:36 – 07:04) Using moving averages to analyze market trends. Indicators of trend changes and their implications. Automating Trading Logic with MQL5 (07:04 – 07:33) Simplifying trading decisions through automation. Using MQL5 for implementing trading strategies. Backtesting and Real-Time Testing (07:33 – 08:04) Importance of backtesting and real-time demo account testing. Evaluating system performance in different market phases. Scaling Up and Risk Management (08:04 – 08:21) Strategies for scaling up the trading system. Adjusting risk percentage and position size. Training and Analyzing Trading Systems (08:21 – 08:51) Training a system for real-world conditions. Using external tools for performance analysis. Conclusion and Future Plans (08:51 – 09:22) Summary of the video and insights on scaling up the system. Invitation to analyze detailed stats on the website.   In this video we are going to talk about one of my real world examples. This is the robot trading system which actually use myself and one of my premium course members wanted to know how something like this works. So let’s have a look at the details. Well, if you have a look at the robot trading system, you can see this is Version 2023 from June. Right now we have the 20 first of October and here we have results and trades all in all we made a profit of 159 dollars and if we look at the overall view here we see that the balance currently is almost equal to the equity which means we only one open trade that is currently and open loss of 99 cents. So what is actually the difference between this trade and one that would be an open loss of 99 dollars? The difference is emotional because it’s not actually the number here that counts if a system is working or not, it’s what the difference means for us. So let’s have a look at the history and here we see that we have losses and we have profits, so not every trade was a success, but all in all the system result is stable, at least right now. If we zoom into the system, we can see these lines here which look like a fan and each of those is a series of positions that we have opened. And at this point here all positions have been closed at once. Let’s zoom in a little more and you will also see parts where we don’t see a fan, for example like here. And these are simple positions that made a profit without the need to start a series. So how do we decide if we just take one position or if we want to open multiple positions? Well in my case I have rules. And currently we are in a down trend, and we can see that because we have two simple moving averages here is for 1100 candles and the other one is for a thousand candles. And a long as the green one is below the red one, we have a downtrend and that looks pretty stable right now. And you can see that the last trades that we made have been sell trades, so we have been trading with the trend. But still we have some positions that didn’t work out. How was that possible? Well that’s because even in a stable trend we have some corrections. That’s when we open a position like here and then suddenly in a correction the price goes up. And if you take a closer look, this is the case for all these fans here. The price went down, than we made a trade here. Suddenly a correction happened and it went against us. But actually we have been able to still close all the positions from here to there in a profit at this point here. Because finally the short time trend again started to go with the main trend and the price went Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - SIMPLY GOOD PLATIN… MQL5 TUTORIAL - HOW TO STILL BENEFIT WHEN THE PRICE… MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM MQL5 TUTORIAL - REAL RESULTS YOU COULD HAVE ACHIEVED IN 2022 Robot Trading System - Free Expert Advisor Download… The post MQL5 TUTORIAL – HOW TO TRAIN AND SCALE A WORKING REAL WORLD TRADING SYSTEM appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – HOW TO CALCULATE THE HISTORY PROFIT

    Play Episode Listen Later Oct 3, 2023 2:56


      Introduction to Calculating Historical Profit (00:00 – 00:09) Introduction to creating an expert advisor for calculating historical profit for a specific currency pair. Overview of displaying the calculated profit on the chart. Starting with MetaEditor (00:09 – 00:16) Instructions on how to start the MetaEditor for coding the expert advisor. Brief mention of using the icon or pressing F4 on the keyboard. Including Trade Library and Creating CTrade Instance (00:16 – 00:31) Explanation of including the Trade.mqh library for trade operations. Creation of an instance of the CTrade class named ‘trade’ for executing buy and sell operations. Calculating Current Ask and Bid Prices (00:31 – 00:38) Description of calculating the current Ask and Bid prices within the OnTick function. Importance of these prices for executing buy and sell orders. Executing Buy and Sell Orders (00:38 – 00:46) Checking for less than two open positions before executing orders. Execution of both buy and sell orders for demonstration purposes. Calculating and Displaying Historical Profit (00:46 – 01:01) Use of the GetCurrencyPairHistoryProfit function to calculate historical profit. Displaying the calculated profit on the chart. Functioning of GetCurrencyPairHistoryProfit Function (01:01 – 01:09) Detailed explanation of how the function calculates total historical profit for a specific currency pair. Initializing Variables and Fetching Historical Data (01:09 – 01:17) Initialization of variables for storing deal information. Use of the HistorySelect function to fetch historical deal data. Iterating Through Historical Deals (01:17 – 01:25) Iteration through historical deals using a for loop. Obtaining profit, swap, and order type for each deal. Ensuring Matching Currency Pair for Deals (01:25 – 01:34) Checking the currency pair for each deal to match the current symbol. Compiling the Code and Further Learning Resources (01:34 – 01:49) Instructions on compiling the code in MetaEditor. Recommendation for the premium course or basic videos for further learning. Testing the Expert Advisor in MetaTrader (01:49 – 02:04) Returning to MetaTrader and starting the strategy tester. Selection of the created expert advisor and enabling visual mode for testing. Invitation for Premium Course Members (02:04 – 02:09) Invitation for premium course members to suggest ideas for new videos. Conclusion and Summary (02:09 – 02:24) Conclusion on how to calculate and display historical profit for a currency pair using MQL5. Emphasis on the functionality of the created expert advisor with minimal MQL code.   In this video, we are going to create an expert advisor that calculates the historical profit for a specific currency pair and displays it on the chart. Let’s see how we can do that. To begin, start the MetaEditor by clicking on the little icon or pressing F4 on your keyboard. The code starts by including the Trade.mqh library, which provides functions and methods for performing trade operations.   We then create an instance of the CTrade class called trade to execute trade operations like buying and selling. Inside the OnTick function, we calculate the current Ask and Bid prices for the symbol. These prices are essential for executing buy and sell orders. The code checks if there are less than two open positions. If true, it executes both a buy and a sell order.   This is just for demonstration purposes. The historical profit for the currency pair is calculated using the GetCurrencyPairHistoryProfit function and then displayed on the chart. The GetCurrencyPairHistoryProfit function calculates the total historical profit for the specific currency pair. Several variables are initialized to store information like the total number of deals, ticket numbers, order types, and profits. The HistorySelect function is used to fetch historical deal data. A for loop iterates through all the historical deals.   For each deal, the profit and swap for the deal are obtained, the type of order (buy or sell) is determined, and the currency pair for the deal is checked to ensure it matches the current symbol. Once you’ve written the code, press F7 to compile it. If this was too fast for you or if you don’t understand what all the code is doing, you may want to check out the premium course on our website or watch one of the basic videos first. After compiling, go back to MetaTrader by pressing F4 or clicking on the icon. In MetaTrader, press control and R to start the strategy tester.   Pick the expert advisor that we have just created, enable the visual mode, and start a strategy test. You should then see the expert advisor on the chart. If you’re already a premium course member and have an idea for a video like this one, please send us an email. In conclusion, you’ve now learned how to calculate and display the historical profit for a specific currency pair using MQL5. With just a few lines of MQL code, you’ve created a functional expert advisor. Thanks for watching, and I’ll see you in the next video! Not sure what to do? Click on the automated trading assistant below MQL5 Tutorial - Advanced Library Expert Advisor MQL5 TUTORIAL - 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE TENKANSEN STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE IVIDYA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – HOW TO CALCULATE THE HISTORY PROFIT appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Order Cancel Order EA

    Play Episode Listen Later Sep 2, 2023 6:41


      Introduction to Order Cancels Order (OCO) System (00:00 – 00:09) Introduction to the concept of OCO, where one order’s execution cancels the other. Visualization of sell stop and buy stop orders on the chart. Understanding Orders and Positions (00:09 – 00:30) Explanation of the difference between an order and a position. How orders become positions when triggered by price movements. Creating an Expert Advisor in MetaEditor (00:30 – 01:01) Instructions on opening MetaEditor and starting a new Expert Advisor project. Naming the project ‘Simple Cancel Order.’ Setting Up the Expert Advisor (01:01 – 01:30) Removing unnecessary lines and importing the ‘trade.mqh’ file. Creating an instance of the CTrade class. Initializing Trading Parameters (01:30 – 02:05) Getting account balance, equity, ask, and bid prices. Normalizing prices for different currency pairs. Creating Buy Stop and Sell Stop Orders (02:05 – 03:28) Conditions for opening pending orders when no positions or orders exist. Setting up buy stop and sell stop orders with defined take profit points. Implementing Order Cancellation Logic (03:28 – 04:49) Checking for active trading and differing balance and equity values. Creating a function to cancel open orders. Compiling and Testing the Expert Advisor (04:49 – 05:32) Compiling the code in MetaEditor. Instructions for testing the Expert Advisor in MetaTrader. Visualizing the Expert Advisor’s Functionality (05:32 – 06:06) Observing the behavior of the Expert Advisor with pending orders in MetaTrader. Explanation of how the Expert Advisor cancels one order when the other is triggered. Conclusion and Summary (06:06 – 06:06) Recap of how to create a simple OCO Expert Advisor in MQL5. Emphasis on the ease of coding this functionality with a few lines of MQL5 code.   Today we want to talk about a system that is called OCO that is the short term for Order Cancels Order. If you look on our chart we have a sell stop here and we have a buy stop there and here is where the price is and if the price moves to the sell stop that would trigger a short position. And if the price rises and hits the buy stop we would have a long position. Now what’s the difference between an order and a position? You use an order if you want to open a position so you can place your orders in the market and if the price moves and hits your pending order it will become a position. You see that we have cancelled the other order now. It’s no longer here, so let’s find out how to create an Expert Advisor that can cancel pending orders. To do that please click on the little button here or press the F4 key and once you have done that piece click on File, New, Expert Advisor from Template, Continue. I will call it Simple Cancel Order, Continue, continue and finish and now you want to remove everything above the OnTick function and the two comment lines here. And to have anything to close we first need to import the file trade mqh by using the include function. We want to create an instance of the Class Ctrade and that will have the name trade. In the first step we need to get the account balance that is done by using account info double, Account_Balance. Now we need to get the equity by using account info double, Account_Equity and we also need the ask prize here we use symbol info Double_Symbol for the current chart and the constant Symbol_Ask. We also use normalized Double_Digits because we have currency pairs with five digits and other currency pairs with three digits and now we do exactly the same to get the bid price, but this time we use Symbol_Bid. Now if we have no open position and no order, so if positions total equals zero and if orders total also equals zero, we need to open a pending order for a buy stop and another one for the sell stop, the position size is ten micro lot. In both cases the buy stop order will be placed one hundred points above the ask price and the sell stop order will be placed one hundred points below the bid price. For the current symbol we have not defined a stop loss, the take profit is three hundred points above the ask price and two hundred, no let’s also use three hundred points below the bid price. We use other time GTC that means the order will stay until we cancel it, so we have no expiration time here. If we would use an expiration time we would use this parameter to define it and the last parameter here is for a comment but we don’t need that. If we are trading right now – that would mean that the balance has different value than our equity. We want to cancel the open orders so let’s create a function called cancel order. It's a void type because it doesn’t need to return any kind of value and here we use For Loop. It starts by using orders total minus one and until the value for the counter is zero that means as long as we have open orders it will go through all the open orders. We use order get ticket for the current order to find out the ticket number and it now will delete the pending orders by using Trade.OrderDelete for the order ticket that we have calculated here. And the last thing we need to do is to close the For Loop and the cancel order function. Now let's compile the code by clicking the little button here or pressing the F7 and that did actually work without any errors. So now please click here or press F4 to go back into Meta Trader. And in MetaTrader you want to click on View, Strategy Tester or press control and R, and here you want to select the Simple Cancel Order.ex5 file, select any currency pair and enable the visualisation mode. Not sure what to do? Click on the automated trading assistant below MQL5 Tutorial - Simple Sell Stop Expert Advisor Embrace the Power of an MQL5 Buy Order MQL5 TUTORIAL - HOW TO CALCULATE THE HISTORY PROFIT MQL5 Tutorial: How to get the Order History Profit MQL5 Tutorial - Advanced Library Expert Advisor The post MQL5 Tutorial – Simple Order Cancel Order EA appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Advanced Library Expert Advisor

    Play Episode Listen Later Aug 27, 2023 6:41


        Introduction to Expert Advisor with Self-Defined Functions (00:00 – 00:14) Introduction to an expert advisor that opens buy stops and calculates profit on a chart. Explanation of using self-defined functions compiled in a library. Understanding Libraries in MQL5 (00:14 – 00:27) Explanation of what a library is in MQL5 and its purpose. How to create a library for reusable functions. Opening MetaEditor and Creating a Library (00:27 – 00:41) Instructions on opening MetaEditor from MetaTrader. Steps to create a new library in MQL5. Setting Up the Library File (00:41 – 01:01) Explanation of import statements and the structure of the library file. Introduction to the functions ‘getProfitCurrencyPair’ and ‘openBuyStop.’ Defining Functions in the Library (01:01 – 01:30) How to define custom functions in the library. Example of creating functions for opening buy stops and calculating profit. Initializing Variables and Importing Trade Functions (01:30 – 02:05) Setting up initial variables and importing necessary trade functions. Explanation of the ‘property library’ directive. Creating Self-Defined Functions (02:05 – 03:28) Detailed steps to create self-defined functions in the library. Example of a function to calculate profit for a currency pair. Implementing the Buy Stop Function (03:28 – 04:49) Creating a function to open buy stop orders. Explanation of parameters and conditions for the buy stop. Compiling and Testing the Library (04:49 – 05:32) Instructions on compiling the library in MetaEditor. How to test the library’s functionality in MetaTrader. Using the Library in an Expert Advisor (05:32 – 06:06) Demonstrating how to use the created library in an expert advisor. Visualizing the expert advisor’s behavior in MetaTrader. Conclusion and Summary (06:06 – 06:25) Recap of how to create and use a custom library in MQL5. Emphasis on the efficiency of using libraries for reusable code.     What you see here is an Expert Advisor that is opening buy stops and we have a calculated profit on the chart and it uses two self defined functions that we have compiled in a so called library. You can think of a library as a file that contains self defined functions that you can use again and again. Now how can we create such a library in MQL5? To do that please click on the little button here in your Meta Trader and now you should see the MetaEditor and this is our main module and we use these import statements here to import the file MyLibrary.ex5 and in that file we have a function called GetProfitCurrencyPair and another function called OpenBuyStop. And in the OnTick function we check if we have no open orders and if that is the case we want to OpenBuyStop so we call the self defined function OpeBuyStop from our library. And to calculate the profit we use the function GetProfitCurrencyPair and that’s also self defined in our library. And to create your own library please click on File, New, Library, Continue, this one is called myLibrary and now you can click on Finish. And the first thing we need is property library, without that you cannot compile the file and to be able to open the buy stops we need to import the trade functions from the built in trade.mqh file. And to get the profit of the current currency pair we need to create our self defined function and this extension 2export” is used because only a function with such a modifier is accessible for our MQL 5 programs. And in the function we declare a variable called ProfitThisCurrencyPair; it contains no value here and now we go through all the positions using this For Loop and we use PositionGetSymbol for the current counter and if the symbol on the chart equals the symbol of the currency pair from our position, we use PositionGetDouble, position_profit to calculate the position profit and position get double, position_swap to calculate the swap. Just add the two values up to get the profit of the currency pair. Let's end the For Loop and we use normalize double and two digits to calculate the profit for the currency pair and format it for two digits behind the dot, and afterwards we use return to return the profit for the currency pair back to the main module. Let’s add another function for the buy stop, it’s called OpenBuyStop and it also has the export extension and to open the buy stop we want to know the ask price, the balance and the equity. You can get the ask price by using SymbolInfoDouble for the current symbol and you use symbol_ask and with NormalizeDouble and _Digits we make sure that we have three digits for this currency pair or five digits for other currency pairs and to get the balance of the equity we use AccountInfoDouble, Account_Balance or AccountInfoDouble, Account_Equity. And if equity and balance are equal, we want to open a buy stop by using trade.buystop for 10 micro lots. The buy stop will be one hundred points above the ask price of the current symbol. We haven’t defined a stop loss, the take profit will be three hundred points above the ask price and we use Order_Time GTC because that is good until the order is cancelled so it will not expire and because of that we use a zero for the date/time and the last parameter would be for the comment, we don’t need that so we also use zero here. Let’s add the last bracket to close the function and press this little button or F7 on your keyboard to compile your library. I made a mistake here, of course I need to create an instance of Ctrade now that’s done and I recompile and this time it worked without any errors. So let’s click on the button here our press F4 to go back to MetaTrader. And in MetaTrader you want to click on View, Strategy Tester or press control and R, and in the Strategy Tester please select the file simpleLibraryMainModule.ex5 and please remember that you also have to Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - HOW TO CALCULATE THE HISTORY PROFIT MQL5 TUTORIAL - SIMPLE SAR STOCHASTIC STANDALONE… Create an MQL5 Expert Advisor with MQL5Tutorial.com MQL5 TUTORIAL - SIMPLE TRIPLE CANDLE STRATEGY How to combine the Parabolic SAR and the Stochastic… The post MQL5 Tutorial – Advanced Library Expert Advisor appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE SAR STOCHASTIC STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Aug 11, 2023 4:21


      Introduction to SAR Stochastic Standalone Expert Advisor (00:00 – 00:10) Introduction to creating an Expert Advisor in MQL5 that uses the Parabolic SAR and Stochastic Oscillator indicators for buy and sell signals. Starting with MetaEditor (00:10 – 00:25) Instructions on opening the MetaEditor from MetaTrader and the initial setup, including importing the ‘Trade.mqh’ library. Setting Up Price Calculation (00:25 – 01:12) Explanation of calculating the asking and bid prices using the ‘SymbolInfoDouble’ function and normalizing these prices. Preparing Price Data Array (01:12 – 01:29) Setting up an array named ‘PriceInfo’ to store price data and sorting it to prioritize the latest data. Implementing Parabolic SAR Indicator (01:29 – 02:17) Using the Parabolic SAR indicator within the ‘CheckEntry’ function to identify potential buy or sell signals. Refining Signals with Stochastic Oscillator (02:17 – 02:45) Utilizing the ‘CheckEntryStochastic’ function to refine trading signals based on the Stochastic Oscillator values. Executing Trades Based on Signals (02:45 – 03:09) Decision-making process for executing buy or sell trades based on the combined signals from SAR and Stochastic indicators. Compilation and Testing in MetaTrader (03:09 – 03:38) Instructions for compiling the code and testing the Expert Advisor in MetaTrader using the strategy tester. Conclusion and Additional Resources (03:38 – 03:53) Recap of the tutorial and an invitation to explore more advanced courses or send ideas for new videos.   In this video, we are going to create an Expert Advisor that uses the Parabolic SAR and Stochastic Oscillator indicators to generate buy and sell signals in MetaTrader. Let’s see how we can do that. First, start the MetaEditor. You can do this by clicking on its icon or simply pressing the F4 key. We begin with the #include directive to import the Trade.mqh library. This library provides us with essential trading functions.   Following this, we create an instance of the CTrade class named trade. This instance will be our primary tool for executing buy and sell orders. Next, we calculate the current asking price using the Symbol Info Double function with the parameters Symbol and SYMBOL ASK. This gives us the price at which we can buy. To ensure precision, we use the Normalize Double function, inputting the price and Digits to adjust the number of decimal places. Similarly, we determine the bid price using the Symbol Info Double function with the parameters Symbol and SYMBOL BID. This is the price at which we can sell. This price is also normalized using the Normalize Double function. We then set up an array named Price Info of type Mql Rates.   This array will store our price data for specific time periods on the chart. Within the On Tick function, we sort our Price Info array using the Array Set As Series function to prioritize the latest data. We then fill this array with price data for the current symbol and time frame using the Copy Rates function. Here, we’re copying data for three candles, giving us a snapshot of recent price movements. The closing price of the most recent candle is then determined using the Price Info[0].close reference. We then call the Check Entry function.   Inside this function, we use the Parabolic SAR indicator to check the current and previous values to determine if there’s a buy or sell signal. If the current SAR value is below the current price and the previous SAR value was above the previous price, it suggests a buy signal. Conversely, if the current SAR value is above the current price and the previous SAR value was below the previous price, it suggests a sell signal. Additionally, the Check Entry Stochastic function is used to refine our signals. This function checks the Stochastic Oscillator values. If the K line crosses the D line from below in an oversold area, it suggests a buy signal. If the K line crosses the D line from above in an overbought area, it suggests a sell signal. With these signals in hand, the code decides whether to execute a buy or sell trade. If both the trading signal and the filter signal return a buy and there are no open positions, the trade.Buy function is used to buy 0.10, equivalent to 10 Micro Lot. If both signals return a sell, the trade.Sell function is used to sell 0.10 Microlot. Once you’ve input all the code, press F7 to compile it.   If this was too fast for you or if you don’t understand what all the code is doing, you might want to check out the Premium course on our website or watch one of the basic videos first. After a successful compilation, return to MetaTrader by pressing the F4 key or clicking on its icon. Once in MetaTrader, press Control and R to start the strategy tester. Select the Expert Advisor you’ve just created, enable the visual mode, and start a strategy test. You should then see the Expert Advisor in action on the chart. If you’re already a Premium course member and have an idea for a video like this one, please send us an email. By the end, you’ll have a deeper understanding of what you’ve learned and the Expert Advisor you’ve coded yourself with just a few lines of MQL code. Thanks for watching, and I’ll see you in the next video! Not sure what to do? Click on the automated trading assistant below How to combine the Parabolic SAR and the Stochastic… How to create a Bollinger Bands Expert Advisor MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE BEARS POWER STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE SAR STOCHASTIC STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE IVIDYA STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Aug 7, 2023 7:15


      Introduction to IVIDYA Standalone Expert Advisor (00:00 – 00:26) Introduction to creating an Expert Advisor in MQL5 for the Variable Index Dynamic Average (IVIDYA) indicator. Explanation of buy and sell signals based on the indicator’s position relative to price candles. Setting Up in MetaEditor (00:26 – 01:01) Instructions on opening MetaEditor from MetaTrader and creating a new Expert Advisor file named ‘SimpleIVIDYAStandaloneEA’. Initial code setup including removing unnecessary lines. Including Trade.mqh and Initializing CTrade (01:01 – 01:30) Explanation of including the ‘Trade.mqh’ file and creating an instance of the ‘CTrade’ class for opening positions later in the code. Calculating Ask and Bid Prices (01:30 – 01:49) Details on calculating the Ask and Bid prices using ‘SymbolInfoDouble’ and normalizing these prices with ‘NormalizeDouble’ and ‘_Digits’. Setting Up Price and EA Data Arrays (01:49 – 02:47) Creating and sorting a price array (PriceArray) using ‘MqlRates’ and ‘ArraySetAsSeries’. Also, setting up an array for the Expert Advisor data (EAArray) and sorting it. Implementing IVIDYA Indicator (02:47 – 04:10) Using the ‘iVIDyA’ function to define the Expert Advisor based on the Variable Index Dynamic Average Indicator. Filling the EAArray with data using ‘CopyBuffer’. Calculating and Assigning Signals (04:10 – 05:02) Determining the current IVIDYA value and assigning ‘sell’ or ‘buy’ signals based on its comparison with the close price of the last candle. Executing Trades Based on Signals (05:02 – 05:29) Executing sell or buy trades using ‘trade.Sell’ or ‘trade.Buy’ based on the calculated signal and the absence of open positions. Displaying Signal on Chart and Testing (05:29 – 06:01) Using the ‘Comment’ function to display the current signal on the chart. Instructions for compiling the code and testing the Expert Advisor in MetaTrader. Conclusion and Demonstration (06:01 – 06:41) Conclusion of the tutorial with a demonstration of the Expert Advisor in action, showing a buy signal and the opening of a position.   In this video we are going to create an Expert Advisor to calculate this Indicator; it's the Variable Index Dynamic Average, whenever the red line is above the price that would be a sell signal and in the other case when the red line is below the candles – like here – that would be a buy signal. Now how can we create an Expert Advisor that is going to actually trade our signal and output our buy and sell signals directly on the chart? 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, I will call this file: “SimpleIVIDYAStandaloneEA”, click on “Continue”, “Continue” and “Finish”. Now we can remove everything that is above the “OnTick” function and let's also delete the two comment lines here. We start by including the file: “Trade.mqh”. Sometimes people ask me where the file is? Well, it's included in MQL5 and we can create an instance of the class: “CTrade” that will be called: “trade” and we are going to use it later on to open positions. Inside of the “OnTick” function we are going to calculate the Ask price and the Bid price. We get the prices by using “SymbolInfoDouble”, we use “SYMBOL_ASK” to calculate the Ask price and “SYMBOL_BID” to calculate the Bid price. With “NormalizeDouble” and “_Digits” we calculate the number of digits behind the dot. Let's create a string variable that will be called: “signal” and we are going to calculate the signal value later on so we don't assign a value right now. We also need to create a price array (PriceArray) that is done by using “MqlRates”, lets sort the array from the current candle downwards by using “ArraySetAsSeries” and with “CopyRates” we fill our array (PriceArray) with price data for the current symbol on the chart and the currently selected period, we are going to start from the current candle 0 (zero) and we need the price for 3 candles – that's for the prices. Now we need to create an array for the Expert Advisor data that will be called: “EAArray”, let's also sort that one by using “ArraySetAsSeries”. Now we actually can define the Expert Advisor by using the integrated “iVIDyA” function. If you mark that one and hit F1 you will see all the parameters for the Variable Index Dynamic Average Indicator, it has only one buffer and the parameters are: the current symbol on the chart, the currently selected period on the chart, here we have a 9, a 12 and a 0 (zero) – so let's click on: “Insert/ Indicators/ Trend/ Variable Index Dynamic Average” and you will see that we have a “Period CMO:” that is 9, the “Period EMA:” that is 12 and the “Shift:” value of 0 (zero) and that's exactly what we use here and the value will be calculated based on the close price (PRICE_CLOSE). So let's use “CopyBuffer” to fill our array (EAArray) with data according to the IVIDYA definition (iVIDyADefinition) we have created here, it's for only one buffer – the first buffer is buffer 0 (zero) – the current candle is also candle 0 (zero), we need data for 3 candles so we use a 3 here and save it in our “EAArray”. So far so good; to get the current value we just look into our “EAArray” and we need the value for the current candle – that's candle 0 (zero) – now we can actually calculate the signal. Whenever the current iVIDyA value (iVIDyAVALUE) is bigger than the close price of the last candle in our price array (PriceArray) that would be a sell signal and that's when we want to assign the word: “sell” to our signal. In the other case if the iVIDyA value (iVIDyAVALUE) is smaller than the price array 1 close price for candle 1 (PriceArray[1].close) that would be a buy signal and now we assign the word: ”buy” to our signal. Whenever our signal equals sell and Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE TENKANSEN STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE IDEMA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE BEARS POWER STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE STANDALONE RANDOM ENTRY EA The post MQL5 TUTORIAL – SIMPLE IVIDYA STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – HOW TO OPTIMIZE YOUR RESULTS

    Play Episode Listen Later Jul 23, 2023 4:42


      https://elopage.com/s/crowdcompany/platinum-demo-system   CLICK AND USE COUPON CODE “PLATINSYSTEMDEMO” FOR A DEMO COURSE & DEMO VERSION   This video is about system testing. This is the new and improved system for the Platinum Group. We now have two signals here and also some other things have been changed. And in this video we’re going to take a look at how to test a system like this. To do that, first of all, we need to select the right expert advisor in MetaTrader. I have now selected here in the strategy tester the version from July the 14th. And that is already the first criterion. You should, when you create a new system, always create a new version for every change, even if it means a little more work. But then you always have the possibility to go back to the last working version if you ever made a mistake. This is today’s date, July the 20th, 2023. So I want to test for a full year. And here on the Inputs tab, I first set everything to the default values. If I now start the test here, then I see the strategy tester with the information on the chart. But we want to save some time. That’s why I’ll pause this here and we’ll do the test without the visual mode. This should be relatively quick in the optimized version. Here, you can already see how the progress is developing. The total test time is given here with about two minutes. And I will fast forward the video to the end of the test in a moment to show what the result is. So as you can see, the system survived. But of course we didn’t make a profit here. The reason is: The default settings are meant to make a system profitable in the long run over a long period of ten or more years. But that can be wrong for some years. And of course you can optimize such values, now. We start here by changing the values for the curve and for the position size and start the test again. Okay, the second strategy test is done. This already looks quite good. However, this could be much more profitable here. So in the next step, I go a little higher with these two values and start the test again. This also worked, but it is not yet profitable. Let’s set the position size to four times because the drawdowns here were not really high. And let’s see if we can optimize this. So this test is also done and this time we are at about 11.3% profit with a moderate risk. That’s about what I see as a realistic profit expectation. Of course, you can go much, much higher here now with these values, but that wouldn’t work for every year. In 2003, I started my testing. I could change this accordingly and that would then work with the default settings for 20 years. But I’m pretty sure these settings here would be too aggressive at some point in this long term test. So we can just test by doubling the values here again and see what happens. Okay, this strategy test is also over. And this time we would have made 45,000 profit. That would be 45% for a $100,000 account. And of course, on this chart here, it all looks totally easy and smooth. But the people who really take profit in trading are the people who can take drawdowns like this here without manipulating their own system. And that always works best when you don’t need the money. And I believe that the percentage of Platinum members who have the nerve to endure such drawdowns, and who also have the money to go through such developments here is above average. And if you are already a Platinum member, then you can use the new version from the Platinum system as an optional update in the next few weeks. I myself don’t like forced updates. That’s why there is always the possibility to continue using the previously approved version. I will use the next few days to do some more extensive testing to make sure that the system does not ship with serious bugs. Nevertheless, it’s safe to say that this is still a version in beta status. If you click on the chart above, you can see how many tests I do every day. And the basic idea is to make such a system more and more stable. And there’s really nothing better for that than a large number of realistic tests. I think that’s it for this video. This test should also be finished in a few seconds. I’m quite happy with the result, because this time we would have made $55,000 profit with a $100,000 account. That was it so far. I say thanks for watching – and see you in the next video.     Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - FREE TRADING TRAINING FOR 2023 MQL5TUTORIAL - HOW TO GET ADVANCED STATISTICS FOR 3 LIVE… MQL5 TUTORIAL - HOW TO GET THE 1000 PLATIN SYSTEM FOR FREE Robot Trading System - Free Expert Advisor Download (below… MQL5 TUTORIAL - PLATIN SYSTEM - WILLIAMS PERCENT RANGE ENTRY… The post MQL5 TUTORIAL – HOW TO OPTIMIZE YOUR RESULTS appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE ITEMA EXPERT ADVISOR

    Play Episode Listen Later Jul 8, 2023 7:19


    This time we are talking about the ITEMA Indicator. This is for the Triple Exponential Moving Average Indicator. You see this red line here. If we pass the strategy test and hover over the red line you will see that it is called the Triple Exponential Moving Average and its calculated based on 14 candles. In this video we are going to find out how to create an Expert Advisor to calculate a Triple Exponential Moving Average Indicator and how to improve the frequency of the signals that are created. To do that please click the little button here in your Metatrader 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” from template (template), Continue (Next). I will call this one: “Simple ITEMA” (SimpleITEMA). Click on continue, continue and finish. Now everything above the “OnTick” function can be removed, let's also delete the two comment lines. First we need to create an array for the prices, that’s done by using “MqlRates” and the array will be called: “PriceArray”. We use the MQL5 built-in function “ArraySetAsSeries” to sort the price array from the current candle downwards and with “CopyRates” we fill the array for 3 candles. That’s enough to calculate the current candle and calculate crossovers. “CopyRates” takes a few parameters, first one is the symbol parameter – that’s for the current currency pair on the chart – the second one is for the currently selected period on the chart. We start with candle zero; that’s the current candle, copy the data for 3 candles and store it in the price array. In the next step we to create another array for the Expert Advisor data, that will be called “EAArray” and the Expert Advisor array also need to be sorted by using “ArraySetAsSeries”. Now it’s time to actually define the ITEMA Expert Advisor. That is done by using the built-in function: “iTEMA”, it takes a few parameters: the first one once again is the currency pair on the chart, the second one is once again the selected period on the chart, these are 14 candles because if you click on “Insert -Indicators -Trend -Triple Exponential Moving Average” you will see that the default value for the built-in indicator also is 14 candles. We use a shift value of 0 here and it applies to the close price, so that’s what we are using here: shift value 0 and “PRICE_CLOSE “. Now that we have created the definition we use “CopyBuffer” for the ITEMA definition (iTEMADefinition) we have created here. The 0 is for the first buffer, this 0 stands for the current candle, the 3 is to copy 3 candles and we want to save it in the array called: “EAArray”. Now that we have done that we calculate the ITEMA value (ITEMAVALUE) for the current candle 0 in our array. I use float, usually it’s a double and if you press F1 you will see that a double variable is 8 bytes in size, a float variable only takes half of the size and it’s better to read for us humans. So, let’s create a chart output depending on the direction. If the ITEMA value is bigger than the close price of the first candle in the price array – remember the first candle is always this one, this is candle zero, candle one, candle two and so on – so, if this expression is true we use the “Comment” function to output the text: “iTEMA IS SHORT”, followed by the calculated ITEMA value. In the other case if the close price for candle one in our price array is above the ITEMA value we will output: “iTEMA IS LONG”, also followed by the value. Okay, that’s it. When you are done you can click on the compile button here, we get a warning that says that we have a possible loss of data due to type conversion, that’s because I used a float variable here but for this little Expert Advisor that is okay. So, if the compilation works without any errors you can click the little button here or press F4 to go back to Metatrader. In Metatrader please click on “View -Strategy Tester” or press CTRL and R and now you should select the file: SimpleITEMA.ex5, mark the visualization option here and start a test. This is how our Expert Advisor looks like, you see it saying: “iTEMA IS SHORT “or “iTEMA IS LONG”. The frequency of the signals is much too high, so let’s fix that! We go back into the Metaeditor and change the shift value for the candles to 100 candles. Let’s recompile the code, press F4, stop the current test and start a new one! This is how it looks like, just press the minus key a few times and now you see that the indicator is calculated 100 candles before the price and whenever the price is crossing here we will get another signal. Let’s speed that up a little bit, now we are getting much fewer signals but the signal quality is better! Okay. That's it! Now you know how to create an Expert Advisor for a Simple Triple Exponential Moving Average Indicator and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 72 SIMPLE TRIPPLE EMA MQL5 Tutorial Classics - Simple Moving Average Robot with… MQL5 TUTORIAL - SIMPLE IDEMA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE SHIFTED SMA EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE SIGNAL STACKING The post MQL5 TUTORIAL – SIMPLE ITEMA EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple External Signals In A File

    Play Episode Listen Later Jun 29, 2023 7:09


    This week I’ve gotten a few requests: how we can use external signals to create buy or sell signals in Metatrader. Right now, our buy signal is “Don’t Buy It Now”, and we have no open positions. And this is a simple text file. It is located in the user’s path in Windows. So that path here might be a little bit different, depending on your name and your operating system, but it should be below MetaQuotes, terminal, common files. Right now, it contains the sentence, “Don’t buy it now”. So let’s see what happens if I remove the Don’t and save the file. Immediately, a new Buy trade appears. So now we have opened a new position by using an external text file. And in this little video, we are going to find out how to do that. In your MetaTrader, please click on the little button here or press the F4 key. And in Metatrader, you want to click on File, New, Expert Advisor from Template, Continue. I will call it simple external signal and finish. And now you can remove everything above the on tick function and the two comment lines here. And to open a trade, the first thing we need is to import the trade.MQH file by using the include function.   And now we want to create an instance that will have the name trade. And inside the ontick function, the first thing we do is to get the ask price by using symbol info double for the current symbol. We use the constant symbol underline ask because we need the ask price. And with normalize double and underline digits, we make sure that we have the right number of digits behind the dot, because there are some currency pairs that have only three digits and others have five. Let’s tell MQL5 actually which file we are going to use. Remember, this is the path where my files are located. In your case, it might be a little bit different, depending on your operating system and your name. This is the File handle, it’s an integer value and we use FileOpen for the file with the name signal.txt. We use File_Read, because we only want to read what’s in the file. File_ANSI means it’s a file that is containing strings of ANSI type. Ansi is only using one byte. You could, for example, also use File_Unicode. That would be used for two byte symbols. So if you see any weird characters on your screen, the reason might be the wrong encoding here.   And File_Common is used for the file path in the common folder of all client terminals. It ends with terminal, common files, like in this case. This pipe character here is used as a delimiter that is used to separate the different items in a txt file or in a comma separated file. And CP_ACP means we are currently using the current Windows ANSI code page. Now that our file is defined, we use File, Read String for the external file we have created here to read out a buy signal. It will be a text string. And afterwards, we close the file. That is done by using the command File Close for our external file. And if no open positions exist and a buy signal occurs, that would mean positions total equals zero and the text in our file is “Buy it Now”. Well, in that case, we want to open a buy position by using trade.buy for 10 micro lots on the current chart for the current Ask Price. We have no stop loss defined. Our take profit is 100 points above the current Ask Price and we don’t need a comment here, so we use null for the last parameter.   The last step is to create a chart output by using the comment function. It will show us the current buy signal that is the text that is contained in our file, followed by the text positions total and the value we have calculated for positions total. And if everything is okay, please click on the compile button. And if you don’t have any errors or any warnings, click on a little button here or press F4 to go back to Metatrader. Now in Metatrader, please click on View, Strategy Tester, or press CTRL and R. And here you need to select the file simple external signals.ex5, enable the visualization and start the test. Now our little expert advisor is running and you see the buy signal right now is: don’t buy it now. The number of open positions is zero. So let’s change the text file here. click on File, Save. And immediately a new trade is opened here. And if you speed up the process, you will see that new trades are opened and closed. But if the external condition is no longer true, or if I change the file content manually and save it, the buy signal will change to stop buying or whatever is in the text file.   Let’s save that again. Now it says, Buy signal is stop buying or whatever is in the text file. Okay, Now you know how you can create an Expert Advisor that can read external Txt files. Actually, you could also use Excel files or whatever to use external signals. And you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below LEARN MQL5 TUTORIAL BASICS - LEVEL 1C BUILD YOUR OWN ALGO… MQL5 TUTORIAL - PLATIN SYSTEM - WILLIAMS PERCENT RANGE ENTRY… MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AWESOME STANDALONE EXPERT ADVISOR MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR The post MQL5 Tutorial – Simple External Signals In A File appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – HOW TO STILL BENEFIT WHEN THE PRICE RUNS AGAINST YOU

    Play Episode Listen Later Jun 24, 2023


      Trading can often feel like a high stakes game where the challenge lies not only in making profits, but also in managing the inherent risks and inevitable lows. That is also true for the robot trading system, a trading tool that is reshaping traditional approaches by emphasizing resilience as much as reward. About a week ago, I set out on a new journey with this live trading system. As with all things new, the onset wasn’t particularly smooth. I found myself in what traders often dread, a drawdown situation. This scenario occurred despite the fact that I had chosen what is a proven strategy, opening a sell position during a downtrend. The unpredictability of the market, however, took its course and I ended up facing the opposite direction of the intended profit.   As a result, for an entire week, my trading account saw no influx of profits. For many, a week without profits might signal an ineffective system. But I beg to differ. While it’s true that the first week didn’t bring any financial gain, the noteworthy detail lies in the absence of losses. It’s crucial to mention here that the robot trading system I was using is designed specifically to handle such draw downs. The system deploys an intelligent algorithm that efficiently hedges positions, thereby maintaining a balance even when the market doesn’t move in the predicted direction. This might seem like a small win, but when you’re trading, especially in a volatile market, avoiding losses can be just as important, if not more, than making significant profits. On the closing date of June 23rd, my account, despite the week’s market turbulence, stood at a net gain of a single dollar.   This may not seem like a significant achievement on the surface, but when considering the context, it’s evidence of the system’s effectiveness in safeguarding against potential losses. For those intrigued by the system’s ability to mitigate losses during unpredictable market conditions, the robot trading system offers a demo account for you to test. This thing provides a risk free opportunity to understand the system’s operations and explore its unique features. The system’s emphasis on resilience and risk mitigation might be a refreshing change from traditional systems that primarily focus on profit generation.   In the world of trading, where the tides can turn swiftly and unexpectedly, it’s a comfort to have a tool that can withstand the push and pull of the market trends. The robot trading system does precisely this by striking a balance between risk and reward. It may not always provide an instant profit, but it offers a buffer against potential losses during turbulent market phases, thus providing a safer trading experience. With its unique emphasis on resilience and a strategic approach to risk management, it stands apart from other trading systems. For anyone seeking a reliable stress tested system that can withstand the unpredictability of the markets, the robot trading system is definitely worth considering. The link is below and as always, thank you for watching and I will see you in the next video.     Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL ENGLISH - 3 COMMON ERRORS CAN LEAD TO… Robot Trading System - Free Expert Advisor Download (below… MQL5 TUTORIAL - IS 3 PERCENT MONTHLY TRADING PROFIT POSSIBLE Metatrader5 vs Metatrader4 LEARN MQL5 TUTORIAL BASICS - LEVEL 1A BUILD YOUR OWN ALGO… The post MQL5 TUTORIAL – HOW TO STILL BENEFIT WHEN THE PRICE RUNS AGAINST YOU appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – BEWARE OF HISTORY QUALITY ISSUES

    Play Episode Listen Later Jun 11, 2023 4:02


    This video, I would like to show you something that you might not know, but you should be aware that all the historical data we see is calculated data, more or less. And I will show you something that is a little bit weird. So if you see the scale here below, we have several months that are listed one behind the other. And suddenly here, we have January the third, January the fourth, and so on. So why is the same scale here much less complex? And that’s because when you zoom into the chart, you will notice that each of those candles here has a value that can be shown when you hover with the mouse over the chart. This is the price for the open, the high, the low, and the close price for November the 15th. And the next candle here will show us the same data for the next day. But actually, we have said that we want to trade on a one hour chart. So what you see with your own eyes here is that for January, we have a price for Midnight. Let’s go a little bit further into the data. This is the next year. And here suddenly we have a price for 10 o’clock. The next candle is for 11 o’clock, and the next one is for 12 o’clock. That is the way it should be. But actually, when you look at the chart like this one, you might probably not notice that up to the date where we started the strategy test, all the data is just one candle per day. Even we have chosen to trade the hourly chart. So basically, this is a quality issue for visual data. And if we start the test here and zoom into the chart, you will see now we have separate candles for each hour. So data quality might be an issue, especially if you’re trading the early years. Let’s do another test. This time I’m using the Euro US Dollar. Here we are. And if we go back in time, you can see we have hourly charts and data that is available for December 2002. Just remember, we have picked to trade from February 2003. So in this case, the data quality is okay. Now let’s pick the whole year. Let’s set that back to the default and start. Now, we should get a result in a few seconds. There we are. And it says that the history quality was 99 %. So if you don’t understand why you have bad results, one of the things that you need to check is the history quality. Let’s repeat the whole thing for the Australian dollar against the Canadian dollar. And here it says the history quality is zero. So make sure to check out the back test tab and the value for the history quality every time you do a strategy test. Okay, so far so good. Thank you for watching and I will see you in the next video. Bye.. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - FREE TRADING TRAINING FOR 2023 MQL5 TUTORIAL - PLATIN SYSTEM - DEMARKER OSCILLATOR MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM MQL5 TUTORIAL BASICS - 79 SIMPLE COLOR CHANGER MQL5 TUTORIAL BASICS - 89 SIMPLE HIGH PRICE TREND LINE The post MQL5 TUTORIAL – BEWARE OF HISTORY QUALITY ISSUES appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – 135 SIMPLE LOT SIZE ROUNDING

    Play Episode Listen Later May 28, 2023 3:32


        In this video, let’s take a look at how to calculate a lot size based on the account balance and how to round up or down the result to make it fit. So let’s take a look at how to do that with MQL Five. To do that, in MetaTrader please click on the icon up here or press the F Four key. Then you should end up in the MetaEditor. And here we click on File, New Expert Advisor from template, next, assign a name here. I have already done this. My file is called Simple Lot Size Rounding and we’ve already pre-programmed this. We’ll start with the on tick function. There we first want to calculate the account balance. This is done using the Account Info Double, Account Balance function and based on the account balance we want to calculate the position size. In our case, we use the gross balance value and divide it by 100,000. We also create two variables for the rounded values, one rounded up and one rounded down. We determine these with the help of the respective function, which we program ourselves.   The first function is called Round up, the second Round down and we pass the calculated lot size and the value for the decimal rounding as parameters. We want to round this to one decimal place. With Normalize Double, we can output the final results in a more formatted way. Although we have specified two decimal places here, we see that our results are truncated after the first digit. And using the Comment function, we output the whole thing on the chart. Let’s move on to the actual functions. To round up, we pass our input value. That’s the position size that we passed above and our rounding value. Let's add the second parameter here for the decimal places. And to get the result, we multiply the rounding value by the result of this function. If you press F1 once and call that up in the help, you’ll see that there’s an integer value returned. And as parameters, we pass the input value and the rounding value to the MathCeil function. Then we use Return to return our result back to the function. The second function for rounding the value works similarly.   Here, however, we do not use MathCeil, but MathFloor. And here we also return the result to our main function. And this then results in the rounded up value 0.3 and the rounded down value 0.2 for a determined lot size of 0.25 lot. Depending on which account type you have, you can adjust this accordingly and thus pass the correct values so that a position can also be opened correctly. Because not all content types support the staggering in microlot sizes down to the second decimal place. By the way, this was again a request from a premium customer. And if you are a premium customer and have an idea for such a video, just send me an email. Otherwise, you can find the premium course on our website. And in this video, you learned how to easily round up or round down lot sizes so that that fits your account type. And you programmed that yourself with these few lines here in MQL5.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 112 SIMPLE BUY PERCENTAGE RISK MQL5 TUTORIAL BASICS - 107 SIMPLE ARRAY REFERENCE MQL5 TUTORIAL BASICS - 108 SIMPLE IOBVEA OSCILLATOR MQL5 TUTORIAL BASICS - 118 SIMPLE LAST ORDER TYPE MQL5 TUTORIAL BASICS - 110 SIMPLE MULTIPLE INPUT The post MQL5 TUTORIAL – 135 SIMPLE LOT SIZE ROUNDING appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR

    Play Episode Listen Later May 14, 2023 3:35


    In this video we are going to create an Expert Advisor that is able to automatically trade a Bollinger Bands entry signal and a filter for the MacD Oscillator in Metatrader5. Both indicators are very popular and can be combined to create buy and sell signals that can automatically traded with this standalone Expert Advisor. So let's see how to do that in MQL5. Please open the MetaEditor. We start by creating a new Expert Advisor by clicking on File, New, Expert Advisor from template. Let's continue, with the include function to include the file Trade.mqh which comes with MQL5. It provides simplified trading functions and we create an instance of the class CTrade so we can use them.   Afterwards we include two files for the entry and the filter signal. The first one is for the Bollinger Bands and it will give us a trading signal. The second one is for the MacD and it will give us a filter signal. Both files have been coded before as separate modules, so they can also be used for other Expert Advisors. If you want to save time and effort, you can go to MQL5Tutorial.com where you can find the premium course and a lot of precoded source code files in the store. In the next step we need to calculate the Ask price and the Bid price. That can be done by using the function SymbolInfoDouble for the current Symbol on the chart. We use Symbol_Ask to calculate the Ask price and Symbol_Bid to calculate the Bid price. With NormalizeDouble and UnderscoreDigits we can calculate the number of digits behind the dot. Depending on the currency pair, that might be 3 or 5 digits.   With MqlRates we create an Array for prices, called PriceInfo. Inside of the Ontick function we use ArraySetAsSeries to sort our price array from the current candle downwards. Then we can use CopyRates to fill our price array with data. We do that for the current symbol and the currently selected period on our chart, starting from candle 0, for 3 candles and store the result in our price info array. Now let's calculate the current price by looking at the close price of candle 0 in our price info array. We create a string variable for the Trading Signal and call the function CheckEntryBollinger to check for a buy or sell signal. And we do the same thing for a string variable called Filter and call the function CheckEntryMacD to get the filter signal. If the trading signal and the filter both return a buy signal and we have no open positions, we want to use trade.buy to buy 10 Micro Lot. In the other case, if the trading signal and the filter both return a sell signal, we use trade.sell to sell 10 Micro Lot. Finally, we use the Comment statement to output the trading signal and the filter on our chart. Press F7 to compile the code, if that works without any errors, you can return to Metatrader by pressing the F4 key.   Okay, if everything went well, you should now have a working standalone Expert Advisor for the Bollinger Bands signal and the MacD filter. You can run a strategy test like this one by pressing Control and R in Metatrader5. If you want to improve your trading results, you can find the premium course and more source codes on MQL5TUTORIAL.com and in our shop. Thank you for watching and I will see you in the next video. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - 131 STANDALONE EMA MACD EXPERT ADVISOR MQL5 TUTORIAL BASICS - 132 STANDALONE BOLLINGER BANDS RSI… MQL5 TUTORIAL BASICS - 129 SIMPLE BOLLINGER BANDS EXPERT… MQL5 TUTORIAL - SIMPLE VOLUMES FILTER MQL5 TUTORIAL - SIMPLE MACD STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE BEARS POWER STANDALONE EXPERT ADVISOR

    Play Episode Listen Later May 7, 2023 6:06


    In this video we are going to talk about this Indicator, it’s the Bears Power Indicator and we want to create an Expert Advisor that is able to actually produce signals that will be seen right here on the chart and in this case we use the Bears Power Indicator tool trade automated. Usually this Indicator is used as a filter and you would use another signal and only when the signal and the filter are pointing in the right direction you would open a new position. To code that please click on the little button here or press F4 on your keyboard, 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 one: “SimpleBearsPowerStandaloneEA”, 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 contains some trading functions. We need 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. Inside of the “OnTick” function we calculate the Ask price and the Bid price, that’s done by using “SymbolInfoDouble” for the current symbol on the chart, “SYMBOL_ASK” will give us the Ask price while “SYMBOL_BID” will give us the Bid price and with “NormalizeDouble” and “_Digits” we calculate the right number of digits after the decimal point. We also need to create a string for the signal, that string variable will also be called: ”signal” and so far we don’t have any value because that is going to be calculated later. Let's create an array for the price data that will be called: “PriceInformation” and we use “MqlRates” to create it because “MqlRates” is the structure that stores the information about prices, volumes and spread. We sort the array downwards from the current candle by using “ArraySetAsSeries” and with “CopyRates” we fill the array (PriceInformation) with price data for the current symbol on the chart and the currently selected period. We start with the current candle 0 (zero) and we need price data for 3 candles – that’s enough – and store the result in our price information array (PriceInformation). Now let’s create another array called: “myPriceArray” this one is for the Expert Advisor data, the other one was for the candle prices. The second array also needs to be sorted downwards by using “ArraySetAsSeries”. Now we use the “iBearsPower” function that comes with MQL5 for the current symbol and the currently selected period on the chart, the last parameter 13, is the number of candles that you also will see when you drag the Bears Power Oscillator on your chart. Now we use “CopyBuffer” for the bears power definition (BearsPowerDefinition) that we have created here to calculate the values for buffer 0 (zero) – that’s the first buffer – from the current candle 0 (zero) for 3 candles and store the result in our price array (myPriceArray) that makes it possible to calculate the current array value by looking at candle 0 (zero) in our price array (myPriceArray) and we store a result in the bears power value (BearsPowerValue) and if the “BearsPowerValue” is above 0 we would consider that to be a buy signal so we assign the word: “buy” to our signal. Otherwise if the “BearsPowerValue” is below 0 we consider that to be a sell signal so now we assign the word: “sell” to our signal and if the signal equals sell and we have no open positions we use “trade.Sell” to sell 10 micro lot. Otherwise if the signal equals buy and we have no open positions we would use “trade.Buy” and buy 10 micro lot. Finally we create a chart output that is done by using the “Comment” function and we want to output the words: “The current signal is:” followed by the calculated “signal”. Now let’s compile the code, we don’t have any errors and in that case we can click here or press F4 to go back to Metatrader. In Metatrader we click on: “View/ Strategy Tester” or press CTRL and R, you will select the “SimpleBearsPowerStandaloneEA”. Let’s also enable the visualization option here and start your test. …and here is our little example at work, we have buy and sell signals, usually you would use the Bears Power Oscillator to filter another entry signal but now you know how to code a standalone Expert Advisor for Metatrader 5 and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - BEARS POWER OSCILLATOR MQL5 TUTORIAL - SIMPLE VOLUMES FILTER MQL5 TUTORIAL - SIMPLE SAR STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE MACD STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE BEARS POWER STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – IS 3 PERCENT MONTHLY TRADING PROFIT POSSIBLE

    Play Episode Listen Later Apr 30, 2023


      Today I got another request from an interested, starting MQL programmer who asked me if it was possible to make at least 3% profit in a month. In fact, I heard that even Warren Buffett as an investor can only make about 20% profit in a year and he is one of the richest men in the world. A 3% monthly profit would equate to an annual profit of about 36%, which is much higher than Warren Buffett’s average return. Now, does that mean that’s not possible?   Well, actually it is rather the case that a profitable solution over a longer period of time is difficult to implement if you want or need to achieve at least 3% per month. The idea is basically not to make a particularly high profit immediately, but to make as few mistakes as possible, especially in the initial phase, and to lose as little money as possible. The majority of all beginners lose a large part or even the entire trading capital within a few months. So the first step is not to optimize profits, but to limit losses while you are still learning and have enough capital. The second problem with this is that every month is slightly different. You can’t think of profits from automatic trading as a regular salary. There may be months when you make minus. In return, you may make a little more plus in another month. In addition, there is the problem that people always tend to question their own system and want to improve it.   If you can’t stick to your own rules, you will realize by the third or fourth exception at the latest that you did exactly the wrong thing at exactly the wrong time. This can lead to being frustrated and out of that comes such things as revenge trades. Humans are emotional and that leads to situations always arising where we feel uncomfortable or do rash things. The intention behind it may be good, but often the result is quite disastrous. Many people also see automatic trading as a kind of fortune telling or a substitute for gambling. But in fact it is more about statistical probabilities. And that means that there can be deviations from the norm.   An average profit expectation does not mean that you should expect that for every week or month you trade. If you are not able to sustain your own trading system over a long period of time, you will basically have a hard time. Regardless of whether you prefer automatic or manual trading. To be successful, it is important to develop a solid strategy, stick to your own rules and avoid emotional decisions. This is the only way to be successful in trading in the long run and make steady profits. At the same time, one should have realistic expectations and be aware that trading is not a fast track to riches, but rather a discipline that requires time, patience and constant learning.   Constant testing and adapting to changing market conditions is essential to be successful in the long run. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - REAL RESULTS YOU COULD HAVE ACHIEVED IN 2022 MQL5 TUTORIAL - PLATIN SYSTEM - SIMPLY GOOD PLATIN SYSTEM… MQL5 TUTORIAL - HOW TO OPTIMIZE YOUR RESULTS MQL5 TUTORIAL ENGLISCH - POSSIBLE OR PROBABLE? MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM The post MQL5 TUTORIAL – IS 3 PERCENT MONTHLY TRADING PROFIT POSSIBLE appeared first on MQL5 Tutorial.

    Choosing the Best Stop Loss Percentage Solution for Stock and Forex

    Play Episode Listen Later Apr 23, 2023


    In the ever-changing world of the trading market, knowing how to protect your investments is essential. One of the most popular ways to do this is by using a stop-loss order. A stop-loss order is an essential tool in any trader’s arsenal, but what is the best stop loss percentage to use? In this comprehensive guide, we’ll explore various stop-loss strategies and help you determine the optimal percentage for your trading style. What is a Stop-Loss Order? A stop-loss order is a type of trading order designed to limit an investor’s loss on a position in the stock market. It works by automatically closing a position when it reaches a predetermined price, known as the stop-loss level. This helps traders protect their capital and minimize losses during times of strong market movements. Types of Stop-Loss Orders [Stock and Forex] There are several types of stop-loss orders, including traditional stop-loss, trailing stop-loss, and stop-limit orders. Each type has its own unique advantages and disadvantages, but they all serve the same purpose: to limit your losses in the market. Factors to Consider When Determining the Best Stop Loss Percentage When determining the perfect stop loss percentage for your trading strategy, several factors should be taken into account. These include: Volatility: The price fluctuations can greatly affect the effectiveness of your stop-loss order. Volatile times may require a larger stop loss percentage to avoid getting stopped out too frequently. Support and resistance levels: Identify key support and resistance levels in the stock’s price movement. Placing your stop-loss order near these levels can help protect your position, because these are levels where most people pay attention to price changes. Trading style: Day traders may use tighter stop-loss percentages to minimize losses, while longer-term investors may prefer more wiggle room to ride out fluctuations in the market. If you prefer long term trading, you need to take swap cost into consideration. Risk tolerance: The optimal stop loss percentage for you depends on your risk tolerance. A more conservative investor might opt for a lower percentage, while a more aggressive trader may be willing to accept a higher level of risk. At the end it depends on what you can actually endure without manipulating the system. Popular Stop-Loss Strategies Percentage method: Set your stop-loss order a certain percentage below the stock’s current price or entry point. For example, if you bought at $100 and set a 5 percent stop-loss, your order would automatically close the position if it dropped to $95. Moving average method: Use a moving average (such as the 50-day or 200-day moving average) as a reference point for setting your stop-loss order. This strategy can help you adapt to changing market conditions and trends. ATR (Average True Range) method: The ATR is a measure of volatility that calculates the average range of price movement over a specified period. By multiplying the ATR by a certain number, you can determine an appropriate volatility stop loss level based on the stock’s volatility. Support level method: Set your stop-loss order just below a recent support level. This strategy helps protect your position while allowing for normal market fluctuations. The Importance of a Well-Defined Stop-Loss Order Strategy Having a clear stop-loss order strategy in place is crucial for successful trading. It allows you to predetermine your maximum loss, manage risk effectively, and prevent emotional decision-making in times of market uncertainty. By considering factors like volatility, support and resistance levels, and your personal trading style, you can determine a better stop loss percentage for your unique situation.   How to find the perfect stop loss order percentage? When engaging in trading, it is essential to have a personalized and well tailored stop loss policy in place to shield your money from potential losses. A stop loss should protect an investor from suffering severe losses, but determining the appropriate amount of the stop loss can be difficult. For most traders, their own stop loss order is to blame for eighty percent of the losses that they had hoped to avoid. Therefore, what would be the best approach to take? First and foremost, investors need to be aware that there are several distinct types of stop loss strategies, such as fixed, trailing, and dynamic stop loss strategies. Each kind has its own set of pros and cons, and the trader’s decision as to which one to use depends on the level of risk he or she is willing to take and the current state of the market. There is a school of thought among traders that a predetermined percent stop loss is the most foolproof choice.   Each stop loss solution comes with a cost! When it comes to stop loss solutions there is something every investor needs to understand: there is no free lunch! Each solution comes with a cost, and it is crucial to calculate that upfront. However, in my opinion, there is one solution that beats them all. It is called the equity stop. Now, you might be wondering what an equity stop is and why it is more effective than all other solutions. Well, let me inform you that most people don’t know about this hidden gem in the world of investing. Unlike other stop loss solutions, the equity stop puts a stop loss order on the amount of equity based on the account. This means that an investor sets a percentage at which they will exit their position, based on the amount of account equity they have. It is a more flexible and dynamic solution that allows for adjustments according to the account monetization. It is less restrictive than other solutions and provides greater control over risk management. Remember, when it comes to investing, it’s not just about the profits – it’s also about minimizing losses. Therefore, if you are looking for a stop loss solution that does not come with a high cost, consider the equity stop. It may just be the answer you’ve been searching for!   Should I use a fixed or dynamic solution? Not sure what to do? Click on the automated trading assistant below MQL5 Tutorial - Advanced Trailing Stop MQL5 Tutorial - Simple Sell Stop Expert Advisor Metatrader5 vs Metatrader4 MQL5 TUTORIAL EXAMPLES - THE COMMENT COMMAND MQL5 TUTORIAL BASICS - 84 SIMPLE BOLLINGER BANDS SELL… The post Choosing the Best Stop Loss Percentage Solution for Stock and Forex appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – Simple Moving Average – Do I need an SMA for my trading strategy?

    Play Episode Listen Later Mar 14, 2023


    What is a simple moving average? A simple moving average (SMA) is a basic technical analysis indicator commonly used in financial markets. It is a calculation of average price over a certain period of time, where each data point is given equal weight. The SMA is a widely used tool for traders and investors, as it can help to identify trends and potential opportunities. For example, a trader may use a 50-day SMA to determine an overall trend in a stock's price. If the stock's price is consistently above the SMA line, it may indicate a bullish market trend. Conversely, a trader may interpret a stock's price consistently below the SMA line as a bearish trend. The SMA can be customized to fit different timeframes and periods, making it a versatile tool in technical analysis. While SMA is a relatively simple indicator, it can be a valuable tool for investors and traders to help identify potential trading opportunities. Moving averages are an important analytical tool used to identify current price trends and the potential for a change in an established trend. The utilization of moving averages is significant in the realm of analysis as it enables recognition of the present price tendencies and likelihood of a shift in a preexisting trend. Why should I use a simple moving average? As an aspiring trader or investor, you might wonder why you should use a simple moving average (SMA). The answer lies in the usefulness of this technical tool in identifying trends in the market. By calculating the average price of an asset over a specific period, SMAs give a clear picture of its movement and direction. This makes it easy to understand the overall trend and take advantage of potential opportunities. Moreover, SMAs are widely used by thousands of traders across multiple markets, making it a reliable and trusted tool in the trading community. By utilizing SMAs, you gain greater insight into market movements and improve your chances of making profitable trades. What is the best setting for Simple moving average? When it comes to determining the best setting for a simple moving average, there is no one-size-fits-all answer. This is because the optimal settings for an SMA depend largely on your personal trading strategy as well as whether you’re focused on long-term or short-term trading. For example, a day trader may find that a 15 or 20-day SMA provides the best signals for making quick decisions given the volatility of intraday price movements. On the other hand, for those focused on longer-term trades, a higher SMA setting between 50 and 200 days (the 200-day SMA is popular) can help capture long-term trends more effectively. In short, the best setting will depend on factors like the timeframe of trades, the market being traded, and the level of volatility. Ultimately, finding the optimal SMA setting requires trial and error, as different traders will have different preferences and goals when using moving averages.   Should I use a simple or exponential moving average? The decision to use a simple or exponential moving average depends on the individual trader’s strategy and goals. Simple moving averages weight all candles equally, providing a smoother and less responsive signal. In contrast, EMAs put a higher weight on current candles, making them more responsive to recent price movements. If a trader believes that current events are more important in predicting future price movements, then an EMA may be preferred over an SMA. However, if a trader is looking for a more long-term trend signal, a simple moving average may be more appropriate. Ultimately, traders should experiment with both types of moving averages and decide which one works best for their trading style and goals. What is a weighted moving average? A weighted moving average is a common technique used in statistical analysis to smooth out a data set. It is a type of moving average where different time periods are assigned different weights in the calculation. This is in contrast to a simple moving average (SMA) which assigns equal weight to all time periods. The weights assigned in a weighted moving average can be based on various factors such as importance and relevance of data points. The exponential moving average (EMA) is also a type of weighted moving average, where more weight is given to recent data points. The purpose of using a weighted moving average is to reduce the effect of noise or outliers in the data and provide a clearer trend analysis. What is a crossover strategy? Using two moving averages in combination can result in the creation of signals indicating crossovers. When calculating crossover signals, it is possible to employ a combination of two distinct moving averages. A bullish crossover occurs when the shorter moving average crosses above the longer moving average. This is also known as a golden cross. A bearish crossover occurs when the shorter moving average crosses below the longer moving average. A crossover can indicate an uptrend or a downtrend. Price action and price movement for the SMA can be calculated by adding Multiple moving averages can be used to confirm trends Multiple moving averages can be a great tool to confirm long term trends. Using 3 or more moving averages, such as the popular triple SMA (Simple Moving Average) strategy, can help to smooth out short term volatility and provide a clearer picture of the direction of the market. By plotting the moving averages on a chart, traders can identify when they cross over each other, indicating a potential change in trend direction. If the prices are consistently trading above the moving averages, it suggests a bullish trend, whereas if the prices are consistently trading below the moving averages, it indicates a bearish trend. Overall, incorporating multiple moving averages into technical analysis can lead to better decision making and more accurate trading strategies. How do I calculate a Simple Moving Average (SMA)? The SMA is calculated by taking the average price of an asset over a specified time period. The formula Not sure what to do? Click on the automated trading assistant below MQL5 Tutorial Classics - Simple Moving Average Robot with… Choosing the Best Stop Loss Percentage Solution for Stock… MQL5 TUTORIAL BASICS - 69 SIMPLE PRICE CORRELATION MQL5 TUTORIAL BASICS - 117 SIMPLE MULTIPLE CHART TREND MQL5 TUTORIAL - Mastering the Bollinger Bands Indicator for… The post MQL5 TUTORIAL – Simple Moving Average – Do I need an SMA for my trading strategy? appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE IDEMA STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Mar 12, 2023 6:37


    In this video we are going to create a standalone Expert Advisor for the Double Exponential Moving Average Indicator; it’s the red line here and whenever it crosses our price it will produce either a buy or a sell signal and now we are going to find out how to create an EA that is able to actually trade the signals automated. To do that please click on the little button here or press F4 in 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 give it the name: “SimpleIDEMAStandaloneEA”, click on “Continue”, “Continue” and “Finish”. Now we can delete everything above the “OnTick” function. We start by including the file: “Trade.mqh” that is part of MQL5, now we create an instance of “CTrade” that will be called: “trade”, let’s remove the two comment lines here. Inside of the “OnTick” function we calculate the Ask price and the Bid price by using “SymbolInfoDouble” for the current symbol on the chart, “SYMBOL_ASK” will give us the Ask price while “SYMBOL_BID” will give us the Bid price and with “NormalizeDouble” and “_Digits” we calculate the number of digits behind the dot because some currency pairs have 3 and others have 5 digits behind the dot. Now let’s continue by using “MqlRates”, we create an array for the price data that will be called: “PriceInfo”, we sort the price array (PriceInfo) from the current candle downwards that is done by using “ArraySetAsSeries” for the price info array (PriceInfo) we just created and by using “CopyRates” we fill the array (PriceInfo) with price data, that is done for the current symbol and currently select a period on the chart, we start with candle 0 (zero) – that’s the current candle – and we copy the prices for 3 candles and store it in the price info array (PriceInfo). We also need to create a signal that is a string type variable, this is an empty value because we need to calculate the value later on. Let's create an array for the price data of the Expert Advisor that will be called: “MyEaArray” and we define the properties for the Double Exponential Moving Average by using the built in “iDEMA” function that comes with MQL5 for the current symbol and the currently selected period on the chart. We will calculate the result based on 14 candles without any shift to the right or to the left and we use “PRICE_CLOSE” to calculate the results based on the close price. Now when you click on: “Insert/ Indicators/ Trend/ Double Exponential Moving Average” you will see that we here also see the period of 14 candles, the shift value of 0 (zero) and it is applied to the close price so that’s what we use here. Let’s sort that array also by using “ArraySetAsSeries” and use “CopyBuffer” to fill it according to the my moving average definition (movingAverageDefinition) that we have created here for buffer 0 (zero) – that’s the red line here – from the current candle 0 (zero) for 3 candles and store the values in our price array (MyEaArray). Now we can calculate the Expert Advisor for the last finished candle – that’s candle 1 in our EA array – (MyEaArray) and we assign the result to the variable “myMovingAverageValue” and if that moving average value (myMovingAverageValue) is bigger than the close price for candle 1 in our price info array (PriceInfo) that would be a sell signal and in that case we assign the word: “sell” to our signal. Otherwise if the moving average value (myMovingAverageValue) is below the close price for candle 1 in our price info array (PriceInfo) – that’s when we want to buy – so now we assign the word: “buy” to our signal. So if our signal equals sell and “PositionsTotal” is below 1 – in other words we don’t have any open positions – that’s when 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” and buy 10 micro lot. In the last step we are going to use the “Comment” function to output the words: “The current signal is:” and the calculated “signal” directly on our chart. Don’t forget the closing bracket here and when you’re done please click on the “Compile” button or press F7, that worked without any errors, so now we can click here or press a F4 to go back to Metatrader. And in Metatrader we click on: “View/ Strategy Tester” or press “CTRL and R” here we pick the file: “SimpleIDEMAStandaloneEA.ex5”, mark the visualization option here and start a test. …and here we go, our Expert Advisor is already trading and now you know how you can create an MQL5 EA that is able to actually trade the Double Exponential Moving Average signal and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AWESOME STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE SHIFTED SMA EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE IFRAMA STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE IDEMA STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE TRIPLE CANDLE STRATEGY

    Play Episode Listen Later Mar 4, 2023 3:44


      In this video, we are going to create a very simple strategy that will open a trade whenever we have three bullish candles in a row. This is a very simple strategy, but it works actually okay.   So let’s find out how you can create an expert advisor like this one with MQL5.   Let’s take a look at the source code for our expert advisor. We start here with an include command. With this, we import trade.mqh. This is a library that provides simplified trading functions. With this, we can create an instance of the class Ctrade with the name trade. In the function itself, we determine the price using symbol info double for the current currency pair on the chart. We want to determine the ask price and with underscore digits we get in combination with normalized double the correct number of decimal places for the respective currency pair. We repeat the whole thing here again with the bid price. The line is so far identical except for this part where we use symbol underscore bid. We are also interested in the growth balance. We determine this with account info double and here we pass as parameter account_balance. For the net balance called equity, we repeat this again. But in this case we use account underline equity as parameter. After that, we create a price array with the name price info using MQL rates. Using array set as series, we can now sort our price info array from the current candle downward.   And using copy rates, we now fill the price array for the current currency pair and the time unit selected on the chart. We start from candle zero and fill the array with the value for four candles, which we store in our price info array. Why do I use four candles here? Quite simply, in the experiment, you can swap the numbers around here because candle zero is the current candle and the result changes quite a bit if you omit the current candle. For now, we want to find out if the closing price for candle zero in our price info array is greater than the opening price for candle zero. If it is, we have a bullish candle. We then repeat the whole thing again here for the closing prices and the opening prices of candle 1 and candle 2 and immediately, if we have three bullish candles in a row, we want to know if the current number of positions is zero. If it is, then we would like to open a position. To do this, we use trade sell to open a position for 10 micro lot. Finally, we use the comment command to display the value for the balance, that is, the gross balance and the value for the equity on the chart.   That’s about it for the most part. When you’re ready, you can pop up the toolbar here at the top and click compile or press the F7 key. That should work here without any errors. And if it does for you, then you can click on this little icon up here or press F4 to return to Metatrader. Now here we are going to run our new Expert Advisor simple triple bullish candle. If the strategy tester is not displayed, you can show it here via the menu or with the key combination control and R. Let’s start our test. Then you can see here already the first graphical development and you have programmed this yourself with this few lines here in MQL5.   Okay, if everything went well, you should already have the expert advisor running here. I hope it worked for you. If you don’t know what all the MQL5 code means or if this was too fast for you, you maybe want to open one of the other basic videos in our channel, or maybe the premium course on our website might be interesting for you. For now, I would like to say thank you for watching and I will see you in the next video.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - 134 STANDALONE BOLLINGER MACD EXPERT ADVISOR MQL5 TUTORIAL BASICS 111 - SIMPLE STANDARD DEVIATION EA MQL5 TUTORIAL BASICS - 105 SIMPLE SELL GRID SYSTEM MQL5 TUTORIAL BASICS - 108 SIMPLE IOBVEA OSCILLATOR MQL5 TUTORIAL BASICS - 120 SIMPLE RSI BUY STOP The post MQL5 TUTORIAL – SIMPLE TRIPLE CANDLE STRATEGY appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE STANDALONE RANDOM ENTRY EA

    Play Episode Listen Later Feb 25, 2023 5:21


    In this video we are going to create a Standalone Expert Advisor that is going to trade random entries. It creates buy and sell signals directly on the chart, here is our first open position and now we are going to find out how to create something like this in and MQL5. 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: “SimpleStandaloneRandomEA”, click on “Continue”, “Continue” and “Finish” and now we are going to delete everything above the “OnTick” function and the two comment lines here. We start by using the “include” function to include the file: “Trade.mqh” that one comes with MQL5 and it allows us to create an instance of the class “CTrade” that we will call: “trade” and we are going to use it later on to open new positions. Inside of the “OnTick” function we want to calculate the Ask price and the Bid price that’s done by using “SymbolInfoDouble”, the first parameter is for the current currency pair on the chart, the second one will deliver the Ask price or the Bid price, it depends on if we use “SYMBOL_ASK” or “SYMBOL _BID” and “NormalizeDouble” and “_Digits” will make sure that we get the right amount of digits behind the dot. Now we use “MqlRates” that structure stores the information about prices, volumes and spread for the candles. We sort the price info array (PriceInfo) downwards from the current candle by using “ArraySetAsSeries” and with “CopyRates” we fill our price info array (PriceInfo) for the current symbol and the currently selected period on the chart with price data from the current candle 0 (zero) for 3 candles. Now let’s create a string variable called: “signal” that will be used to calculate the signal later on, right now it’s empty and here comes the interesting part; we use ”MathSrand” and “GetTickCount” to initialize the random generator because we want to calculate a random number. We use “MathRand” %2 because “MathRand” can return a pseudorandom integer within the range of 0 to 32,767 but we only need 2 random numbers, so let’s say if the random number is 0 (zero) that would be a buy signal and in that case we would assign the word: “buy” to our signal. Otherwise if the random number is 1 we suppose that this one is a sell signal so we assign the word: “sell” to our signal and whenever the signal equals sell and “PositionsTotal” is below 1 – in other words we don’t have any open positions – 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. Finally we use the “Comment” function to output the words: ”The current signal is:” followed by the calculated “signal” directly on our chart. That’s it, please click on the “Compile” button or press F7, now you should see that it went well without any errors and in that case you can click here or press F4 to go back to Metatrader. In Metatrader we click on: “View/ Strategy Tester” or we press CTRL and R, please select the “SimpleStandaloneRandomEA” file, enable the visualization here and start your test. And now you should see the first trade on the chart, let’s speed that up a little bit here and you see that we have made several trades, in this case we have made a profit and if you have no idea which results you could expect from a random entry you should definitely try this out. Okay. In this video you have learned how to create an MQL5 Expert Advisor that is going to trade random entries and output signals directly on the chart and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - SIMPLE AWESOME STANDALONE EXPERT ADVISOR MQL5 TUTORIAL BASICS - 110 SIMPLE MULTIPLE INPUT MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 Tutorial - Simple Sell Stop Expert Advisor MQL5 TUTORIAL BASICS - 78 SIMPLE MULTI CURRENCY ORDER The post MQL5 TUTORIAL – SIMPLE STANDALONE RANDOM ENTRY EA appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL BASICS – SIMPLE ACCOUNT CHECK

    Play Episode Listen Later Feb 19, 2023 3:26


    In this video, we are going to create a little simple expert advisor to secure your account number. So nobody else will be able to use your expert advisor if not a certain type of account is used. So let’s see how that can be done with MQL5. The account number variable: the first part of the code is the declaration of the account number variable. This variable is used to store the account number that is to be compared against the predetermined number. The OnTick function: the OnTick function is a special function that is automatically called by the Metatrader platform whenever a new tick is received. In this case, the Ontick function is used to call the check account number function, which will be discussed in more detail later. The check account number function: The check account number function is the main function used to verify the account number. It begins by declaring the is licensed account boolean variable and setting it to false. This variable is used to store the result of the comparison between the account number and the predetermined number. The next line of code uses the account info integer function to retrieve the account number from the Metatrader platform and store it in the account number variable. The following line of code uses the account info integer function to retrieve the account type from the Metatrader platform and store it in the account type variable. The next part of the code is an if statement that compares the account number variable to the predetermined number. If the comparison returns true, then the is licensed account variable is set to true and a message is printed to the terminal window. The last part of the code is an if statement that checks the value of the is licensed account variable. If the value is false, then a message is printed to the terminal window. Finally, the function returns the value of the is licensed account variable. You can now press F7 to compile your code and return to the Meta trader by pressing F4. Conclusion: This MQL5 code is used to verify if an account number is true or false. It does this by comparing the account number to a predetermined number and then returning a boolean value of true or false depending on the result of the comparison. Okay, so far so good. If everything worked out as it should, you should now be able to run the expert advisor on the correct account. So let’s change that here. I will stop the strategy tester. Let’s pick the right account here, restart the test, and now we get the output, the account number is true. And in this little video, you have learned how to hard code an account number into your expert advisor to make sure that it is not used by anybody else. Thank you for watching and I will see you in the next video. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 118 SIMPLE LAST ORDER TYPE MQL5 TUTORIAL BASICS - 113 SIMPLE SELL PERCENTAGE RISK MQL5 TUTORIAL BASICS - 112 SIMPLE BUY PERCENTAGE RISK MQL5 TUTORIAL - 135 SIMPLE LOT SIZE ROUNDING MQL5 TUTORIAL BASICS - 75 SIMPLE TIME FILTER The post MQL5 TUTORIAL BASICS – SIMPLE ACCOUNT CHECK appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE TENKANSEN STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Feb 13, 2023 6:51


    In this video we are going to create buy and sell signals and code a standalone version that is able to calculate this one line from the Ichimoku Kinko Hyo, it's called a Tenkan-sen, that's the red line here. Now we want to find out how to do that in MQL5? 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: “SimpleTenkansenStandaloneEA”, click on “Continue”, “Continue” and “Finish”. Now you can delete everything above the “OnTick” function and the two comment lines here. We start with the “include” statement to include the file “Trade.mqh”, that comes with MQL5 and we need it to create an instance of “CTrade” that will be called: “trade” and we will use it to open and close positions later on. We start by calculating the Ask price and the Bid price, this is done by using “SymbolInfoDouble” for the current symbol on the chart, we use “SYMBOL_ASK” to calculate the Ask price and “SYMBOL_BID” to calculate the Bid price. “NormalizeDouble” and “_Digits” will automatically calculate the right number of digits behind the dot. Next we need to create a signal variable for the signal that also will be called: “signal” and we don’t assign a value here. We use “MqlRates” to create a price array called: “PriceInformation”, that one will contain the prices of the candles, we use “ArraySetAsSeries” to sort the array (PriceInformation) from the current candle downwards and with “CopyRates” we fill the price array (PriceInformation) with data for the current symbol on the chart and the currently selected period on the chart. We start from the candle 0 (zero) and copy the price information for 3 candles into our price array (PriceInformation). For the Tenkan-sen we need to create another array and we use the MQL5 function: “iIchimoku”, this one can calculate the Tenkan-sen, the Kijun-sen, the Senkou Span depending on the index buffer that we use, buffer 0 (zero) is for the Tenkan-sen, buffer 1 is for the Kijun-sen and so on. For the parameters we use the current symbol, the currently selected period on the chart, here we have three more values; 9, 26 and 52 and when we click on: “Insert/ Indicators/ Trend/ Ichimoku Kinko Hyo” we will see the same values here so that's how we use them. 9 is for the Tenkan-sen, 26 is for the Kijun-sen and 52 is for the Senkou Span B. In our example we only calculate one of them; that's the Tenkan-sen, so let's use “ArraySetAsSeries” to sort our Tenkan-sen array (TenkansenArray) from the current candle downwards and with “CopyBuffer” we fill our Tenkan-sen array (TenkansenArray) according to the Ichimoku definition (IchimokuDefinition) that we have created here for buffer 0 (zero), we start with the current candle 0 (zero) and we use the data for 3 candles. Now we can calculate the Tenkan-sen value (TenkansenValue) by looking at candle 0 (zero) in our “TenkansenArray”. For our simplified example we would say that whenever the value is above, so the “ThenkansenValue” would be greater than the close price for candle 1 in our “PriceInformation” array, we would consider that to be a sell signal and so we assign the word: “sell” to or signal. In the other case if the “TenkansenValue” is below the “PriceInformation” close price for candle 1 we would consider that to be a buy signal and now we would assign the word: “buy” to our signal. And when the signal equals sell and we have no open positions that's when we would use “trade.Sell” to sell 10 micro lot, otherwise if the signal equals buy and we have no open positions we would use: “trade.Buy” and buy 10 micro lot. We finish by creating a chart output using the “Comment” function to output the text: “The current signal is:” followed by the calculated “signal”. Now this is only one of several values that you could calculate for this Indicator, you can spend hours to learn how to read it and there are also several interpretations but in our simplified case we just go with the red line here so when you are done you can click on the “Compile” button or press F7, that should work without any errors here and if this is the case please click here or press F4 to go back to Metatrader. When inside of Metatrader we click on; “View/ Strategy Tester” or press CTRL and R, here we select the: “SimpleTenkansenStandaloneEA.ex5”, please enable the visualization option and start your test. …and here we are! We have a buy signal right now and whenever the price crosses the red line that would switch to a sell signal. Now you know how to calculate the Tenkan-sen value for the Ichimoku Kinko Hyo Indicator, it's also possible to calculate all the other values here and create specific rules but now you know how to automate the Tenkan-sen and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 106 SIMPLE ICHIMOKU KINKO HYO MQL5 TUTORIAL - SIMPLE AWESOME STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE STOCHASTIC STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE ITRIX STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE TENKANSEN STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – SIMPLY GOOD PLATIN SYSTEM RESULTS (TO ANALYZE AND RETRADE)

    Play Episode Listen Later Feb 4, 2023 2:41


      This video is about the result of 197 days in real trading. Today is February 3, 2023 and I wanted to contribute to the result of my system and have just accidentally started here again a new trade. We will now close the trade because actually I have already reached my goal on the 1 February 2023. The goal with the whole action was to close the system with 10% profit. If you take a look at this, we just crossed $11,000. And here in the the order history you can see that I deposited $10,000 at was as far as I can remember, on July 18 and in fact I exceeded my own profit goal on February 1.   This is the corresponding statistic on my website and if you click here you can have a look at the exact statistics of all data of this system on the FX Blue website. Here one can represent the whole again as total profit. On February 3, just now, I closed the last trade and the first position was opened on July 18, 2022. Overall we have a growth of 10.0% with a monthly growth of 1.4%. The system closed only 68% of all positions in profit and on average we made twelve trades per day over a period of 199 days. Actually, this would only be 197 days if I hadn’t accidentally opened a position when I started this video.   If we take a calculator to help us here and divide the 10% by 197 days and multiply by 365, then we would come to a growth of 18.5% annually. What I find interesting is the equity issue, because here you can see quite well that over the period we traded most of the time the equity was very close to balance. That means we had little drawdowns in the analysis. You can see that we traded exclusively with the Euro US dollar. That was 2408 orders, a gross profit of over $2,000, a gross loss of $1,112 and that results in a total profit of $1,001.28 with a profit factor of 1.9. Here are some additional statistics.   For example, the average trading time in hours. This one is an outlier at 334.9 hours. But on the whole you can say that the vast majority was under 100 hours. fxblue statistics here show a total loss risk of 0%. And you can look at 100 more statistics here. Whoever is interested in it can do that here on the FX Blue side or call the webpage PlatinSystem.com. This is currently redirected, but also here you can have a look at the statistics. And here below is somewhere still the playlist linked. For DSGVO, you have to enable the YouTube content here, but then you can have a look at the playlist. This is the video from day one.   All in all, I documented this a little bit and I’ll add this video in there right now. Personally, I’m very happy with the results and now I’m moving on to the next system. Not sure what to do? Click on the automated trading assistant below MQL5TUTORIAL - HOW TO GET ADVANCED STATISTICS FOR 3 LIVE… MQL5 TUTORIAL ENGLISCH - POSSIBLE OR PROBABLE? MQL5 TUTORIAL - PLATIN SYSTEM - CALCULATING TODAYS… MQL5 TUTORIAL - FREE TRADING TRAINING FOR 2023 MQL5 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM The post MQL5 TUTORIAL – PLATIN SYSTEM – SIMPLY GOOD PLATIN SYSTEM RESULTS (TO ANALYZE AND RETRADE) appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE SHIFTED SMA EXPERT ADVISOR

    Play Episode Listen Later Jan 22, 2023 6:00


    In this video we are going to create an Expert Advisor that is going to output buy or sell signals based on the SMA (Simple Moving Average) here, it’s a Moving Average signal that is created for 50 candles, this one is the current signal and this one is the signal predicted into the future and whenever those two lines cross we either get a buy or a sell signal. When the future SMA is below the other one, we have a buy signal and when the current SMA crosses the future SMA and is below it – like here – we have a sell signal. To create the Expert Advisor 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, please click on “Continue”, I will call this one: “SimpleShiftedSMA”, click on “Continue”, “Continue” and “Finish”. Now we can delete everything above the “OnTick” function and the two comment lines here. We start by creating a string for the signal, this one will also be called: “signal” and we don’t assign a value right now because this one needs to be calculated later on. Let’s create two arrays; one for the current Moving Average and one for the shifted Moving Average, afterwards we define the properties for the Moving Average by using the built in “iMA” function that comes with MQL5 for the current symbol on the chart and the currently selected period, the calculation will be based on 50 candles, here we use a shift value of 0 (zero), the calculation will be for an SMA so we use “MODE_SMA”, that stands for Simple Moving Average and the result will be based on the close price. The second calculation looks almost like the first one, we have two differences here; the first difference is that this one is for the shifted average definition (ShiftedAverageDefinition) and the second one is that we use a shift value of 20 here, this will move our SMA 20 candles into the future, so when we pass this you will see that this is the current candle, this is the current value and this one is the predicted value that is shifted into the future. For both of our arrays we use “ArraySetAsSeries” to sort the current array from the current candle downwards here for the Moving Average array (myMovingAverageArray) and here for the shifted average array (myShiftedAverageAttay) and with “CopyBuffer” we fill our array according to the definition that we have created here for the current buffer 0 (zero) – that’s the first line for our Indicator – from the current candle 0 (zero) for 3 candles and we store the result in our Moving Average array (myMovingAverageArray). For the shifted average it’s the same, the only difference is that the value will be stored in the shifted average array (myShiftedAverageAttay). To get both values we look at candle 0 (zero) either in the Moving Average array (myMovingAverageArray) or in the shifted Average array (myShiftedAverageAttay) and if the average array value (myMovingAverageValue) is above the shifted average array value (myShiftedAverageValue) we would assign the word: “buy” to our signal. In the other case if the average array value (myMovingAverageValue) is below the shifted average value (myShiftedAverageValue) that would be a sell signal so now we assign the word: “sell” to our signal. Last but not least we use the “Comment” function to output the words: “The current signal is:” followed by our current “signal” directly on the chart. Okay, when you’re done you can click on the “Compile” button or press F7, that should work without any errors and if that is the case you can click here or press F4 to go back to Metatrader and in Metatrader we click on: “View/ Strategy Tester”, here we pick the file: “SimpleShiftedSMA.ex5”, mark the visualization option and start our test. …and here we are, currently we have an uptrend, the shifted value is below the current value so that’s a buy signal and as soon as we see a crossover here – like right now – we get a sell signal. So now you know how to create an Expert Advisor that is going to calculate a shifted SMA value and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 114 SIMPLE SHIFTED PRICE EA MQL5 TUTORIAL - SIMPLE SIGNAL STACKING MQL5 TUTORIAL - 131 STANDALONE EMA MACD EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE IDEMA STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE SHIFTED SMA EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE ON BALANCE VOLUME

    Play Episode Listen Later Jan 15, 2023 5:04


    In this video we are looking at this little Indicator, it’s the Onbalance Volume Indicator. Investopedia (www.investopedia.com) says that the Onbalance Volume should show us that whenever the Indicator increases without a significant price change the price should follow and now we are going to find out how to automate the Onbalance Volume Indicator in MQL5. To do that please click on a little button here or press F4 in your Metatrader, now you should see the Metaeditor window and here we click on: “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file: “SimpleIOBValue”, click on “Continue”, “Continue” and “Finish”. Now you can delete everything above the “OnTick” function and let’s also remove the two comment lines here. This is a very simple Indicator, we start by creating an array for the Expert Advisor (EAArray), this one will be a double array so it can hold floating type values, now we use “ArraySetAsSeries” to sort the array (EAArray) from the current candle downwards and to define the Onbalance Volume we use the included function that is called: “iOBV”, so let’s mark that and press F1, here we see that it uses the current symbol on the chart, the currently selected period on the chart and the third parameter is called: applied volume so let’s click on this link and we see that we could use the tick volume or the real volume. In our case we use “VOLUME_TICK”. Now we use “CopyBuffer” to fill our Expert Advisor array (EAArray) according to the IOBV definition (IOBVDefinition) that we have created here for the first buffer… well, a buffer is in our case this line here, some Indicators have more than one buffer for example if I would “Insert/ Indicators/ Trend/ Bollinger Bands”, this one has three different lines, so it uses 3 buffers and the first buffers is always called buffer 0 (zero), the second buffer would be number one and so on. That’s because arrays are zero based in MQL5 so the first item in an array is always called by calling the index zero. Let’s copy the data for 3 candles and the result will be stored in our EA array (EAArray). To calculate the current Onbalance Value (IOBVVALUE) we now need to look at the value for candle 0 (zero) in our EA array (EAArray), remember this one is the current candle so this would be candle 0 (zero), candle 1, candle 2, and so on. Finally we want to create a chart output that’s done with the “Comment” function and it will output the words: “The IOB Value is:” followed by the calculated value, so let’s compile that and this worked without any errors, we only have a minor warning – you see the little triangle here – I have used an int value, let’s try double recompile the code and now the warning is gone, so now that everything is finished we can click on the little button here or press F4 to go back to Metatrader. And in Metatrader we click on: “View/ Strategy Tester”, I select a new file: “SimpleIOBValue”, mark the visualization option here and start a test. …and here we are, this is the value and it’s also drawn on the chart here as you can see, it has one digit behind the dot and this digit is always zero so if I use an integer here recompile the code I will get the warning again but when I restart the test you will see that the digit and the dot are gone, I prefer it this way. …and now you know how to calculate the Onbalance Volume and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 108 SIMPLE IOBVEA OSCILLATOR MQL5 TUTORIAL BASICS - 70 SIMPLE BWMFI OSCILLATOR MQL5 TUTORIAL - SIMPLE VOLUMES FILTER MQL5 TUTORIAL - SIMPLE ITEMA EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AMA STANDALONE EXPERT ADVISOR The post MQL5 TUTORIAL – SIMPLE ON BALANCE VOLUME appeared first on MQL5 Tutorial.

    MQL5 Tutorial – Simple Sell Stop Expert Advisor

    Play Episode Listen Later Jan 8, 2023 5:10


    A sell stop is an order that has been placed into the market and that will be triggered whenever the price is falling below the price level that we have defined, this one has already been triggered, so let's see if we can create another one. Here you see that we have placed a sell stop order and as soon as the price reaches the price level that we have defined a sell position is opened. Now how can we create an Expert Advisor that is able to place such a sell stop? 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 file: “SimpleSellStop”, click on “Continue”, “Continue” and “Finish”. Now we can delete everything above the “OnTick” function and the two comment lines here. We are going to start by using the “include” statement to include the file “Trade.mqh”, this one comes with MQL5 and we use the included “CTrade” class to create an instance that will be called: “trade” and we are going to use it to open our sell stop later on. Inside of the “OnTick” function we get the Bid price, that is done by using “SymbolInfoDouble” for the current symbol on the chart, we use “SYMBOL_BID” to get the Bid price and with “NormalizeDouble” and “_Digits” we make sure that we calculate the right amount of digits behind the dot, that could be 3 digits like for this currency pair or 5 digits like for this one. Let's get the account balance by using “AccountInfoDouble”, “ACCOUNT_BALANCE” and we also want to calculate the equity by using “AccountInfoDouble” ,“ACCOUNT_EQUITY”, so if you mark “AccountInfoDouble” and press F1 you will see examples and here are all the values that you could use. This is all account related information.  Now If we have no open positions and no open orders, so if “PositionsTotal” equals 0 (zero) and “OrdersTotal” also equals 0 (zero) we want to open a new order for a sell stop for 10 micro lot. The difference between a position and the order is that a position is something that has already been triggered, so this is a sell position but when the position is closed we place an order below the current price level and as soon our order is triggered it becomes a position. To do that we use “trade.SellStop” to open an order for 10 micro lot, 100 points below the current price level, we don't use a stop loss here and the take profit should be 300 points below the current Bid price, the last parameters here are used to set an expiration or a comment but we don't need that. Instead we use the “Comment” function to output the current balance and the current equity directly on our chart. Okay, that's it. Please click on the “Compile” button or press F7, and if you don't have any errors here please click here or press F4 to go back to Metatrader. Now in Metatrader we click on; “View/ Strategy Tester” or we press CTRL and R, let's pick the new file here: “SimplesellStop.ex5”, mark the visualization option and start your test. …and here we are! This is our sell stop and it will be triggered as soon as the price level drops below this line here, that has happened now and here is our first open position. Now you know how to code an Expert Advisor that is going to create automated sell stops and you have done it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 Tutorial - Advanced Trailing Stop MQL5 TUTORIAL BASICS - 125 SIMPLE ATR SELL TRAILING STOP MQL5 TUTORIAL BASICS - 82 SIMPLE SMA SELL TRAILING STOP MQL5 TUTORIAL BASICS - 84 SIMPLE BOLLINGER BANDS SELL… MQL5 TUTORIAL BASICS - 121 SIMPLE RSI SELL STOP LOSS The post MQL5 Tutorial – Simple Sell Stop Expert Advisor appeared first on MQL5 Tutorial.

    MQL5 Tutorial Classics – Simple Moving Average Robot with MQL5

    Play Episode Listen Later Dec 18, 2022 6:39


    If you have been trading for a while, chances are high that you have used or maybe you have seen a moving average. This is a moving average and it is a line and you can use it to find out if the current price is above or below the average value of a particular number of candles. This is a moving average for the last twenty candles and if you right click on it, you can change the properties here. So let’s change the period to one and now you see that the moving average for one candle is connecting all the closed prices. This is a bearish candle so it closes here. This is a bullish candle so here is the closing price. Let’s look again at the properties and select one hundred and now you don’t even see the moving average because it’s far above the candles. As traders we use moving averages to find out if it’s going down and that would be the case when the current prices crosses the moving average from the above. Or if it’s going up and that would be the case when the current price crosses the moving average from below. Now how can we create an Expert Advisor for this? Now if you point your mouse on any point of the moving average, you will see a value and you will see that the value would change with very candle. Here it is 0.988749 and the closing price is 0.98848. So let’s create an Expert Advisor for that, to do that please hit this little button here or press the F4 key to bring up the Meta Editor. Now you need to click on new Expert Advisor from template, continue. We will give it the name simple moving average, continue, continue, finish and remove everything above the OnTick function. Let’s remove the two comment lines and the first thing we need is an array to hold our price values. So we will create an array with the name my moving average array and in the next step we need to define how the moving average should look like. We want to give it the name moving average definition and it should be for the current symbol on the chart and for the current used period on the chart. I would like to use the last twenty candles for the calculation. I don’t want to shift it to the right or to the left direction and it should be a simple moving average. That’s what MODE_SMA does for closed price of the candle. Now that we have defined how our simple moving average should look like, we need to sort the price range from the current candle downwards. This is done with arraysetasseries, we do it for the moving average array. And now we want to fill it with prize data, that is done with copy buffer for the defined EA moving average definition. It has only one line so we places a zero here, we want the current candle, this is another zero and we want to copy the prize for three candles so let’s put in a three. And MQL 5 should store the results in the my moving average array. So let’s calculate the current value by assigning the value of my moving average array for the current candle to the my moving average value and the last thing we want to do is to output the current EA on the chart so we use the comment function to print out the text moving average value and the calculated value we created here. Okay let’s compile the Expert Advisor, click this little button or hit the F4 key. And now we want to do a little trick, we now want to insert an indicator for the trend and it should be a moving average and for our calculation we use the twenty candles period, a shift value of zero. It should be a simple moving average and it should be applied to the close price. This is the color I want to choose for the A and I want to have these kinds of lines. So let’s click on okay and here is our visual representation. Now we right click on the chart, go to templates and save the template as tester.tpl because this is the template the Strategy Tester is going to use, when we test our little Expert Advisor. Bring up the Strategy Tester by choosing it from the menu or clicking control and R, select the simple moving average.ex5 file, mark the visualisation option and start the test. And here is how it looks like. Let’s pause the test here and our calculated value is 0.993984 and this is exactly what the current Expert Advisor value for the moving average on a chart currently is. Continue, now it’s 0.994416, well let’s check the current value here and it’s 0.9994416. So it works! Now you know, how you can calculate the current moving average by creating this little Expert Advisor. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 82 SIMPLE SMA SELL TRAILING STOP MQL5 TUTORIAL BASICS - 52 SIMPLE EXTERNAL CANDLE NUMBER EA MQL5 TUTORIAL BASICS - 81 SIMPLE SMA BUY TRAILING STOP MQL5 TUTORIAL BASICS - 42 SIMPLE Accumulation Distribution… MQL5 TUTORIAL BASICS - 66 SIMPLE SHIFTED EMA The post MQL5 Tutorial Classics – Simple Moving Average Robot with MQL5 appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – DEMARKER OSCILLATOR

    Play Episode Listen Later Dec 15, 2022 4:03


      In this little video, we are going to calculate an entry signal for this Oscillator that is called the DeMarker Oscillator. It is not so well known, but we will create an entry signal for it. So let’s see how we can do that with MQL5.   A separate window below the candle chart shows the Demarker oscillator.   It has a scale and two lines.   Most of the time, oscillators are used to filter other signals, but they can also be used to make entry signals, which is what we’ll do here.   To use it, we need to create a separate MQ5 file and put it in the same folder as the other Platin System files.   CheckEntry iDEMARKER mq5 is the name of the file, and CheckEntry is the only function it has.   It will figure out what our entry signal is and send that info back to the main module.   We want to make a string variable for the calculated signal, but we won’t give it a value yet because that will be figured out later.   We need a price array. Please choose the type double as it can hold floating type values.   MQL5 includes a function called iDEMARKER that we can use to define our oscillator.   A few parameters need to be set. The first parameter is the chart’s symbol. The period on the chart is the second parameter.   And the last parameter is used for the number of candles we want to use for our calculation.   When you drag the Demarker oscillator onto one of your charts, you will also see these values.   Now we use array set as series to sort the array that we have created from the current candle 0 downwards.   With CopyBuffer, we put data into the array. We do it  according to our definition from above and calculate values for buffer 0, beginning with the current candle 0 and the next three candles.   Let’s keep going and figure out the current candle’s value by looking at the value of candle 0 in our array. With Normalize Double we can format the value to show 3 digits behind the dot.   To figure out when to buy, we look for a value that is below the lower line. That would be the case then it is below 0.3 !   So it would be a buy signal, and when that happens, we give our signal the word “buy.”   Otherwise, if the value is above 0.7 or above the upper line of the oscillator scale that would be a sell signal, so we put the word “sell” into our signal.   At the end of the function, the signal is sent back to the main module using the return command.   Please don’t forget to save the file!   You don’t need to compile it right now. Just save it and go back to where the OnTick function is in the main module.   There, you need to add the new file to the section that contains the include statements. Using the include statement, followed by the name of the file we have created.   Please use two slashes to comment out any other entry signals, and press F7 or click the Compile button to compile both the main module and the new entry file you just made.   Okay, I hope that the compilation process has worked for you. You should now be able to use the DeMarker Oscillator either as an entry signal or as a filter.   Thank you for watching this video, and I will see you in the next one. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - RELATIVE STRENGTH INDICATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – DEMARKER OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – IDEMA INDICATOR

    Play Episode Listen Later Dec 11, 2022 3:58


          In this video we are going to calculate this little red line here. It is called the double exponential moving average, and we will now create an entry module to calculate buy and sell signals.   This time, we’re going to figure out the IDEMA indicator and use it to calculate a trading system entry signal.   The IDEMA indicator is painted right on the candle chart, and it shows up as a red line. If you point your mouse cursor over it, you will see that it creates a double exponential moving average.   To start, we make a new file called CheckEntry IDEMA and put it in the same directory as the other system files.   The new file will use a function called CheckEntry, and we’ll make a variable called signal that will be used to return our calculated signal at the end of the function.   We’ll also need an array to store price information for a few candles.   Now, we use Array set as Series to sort our array starting with the current candle and going down.   With copy rates we fill our price array with data.   We do it for the current symbol and the currently selected period, starting from the current candle 0 and copy the data for 3 candles to store them in our price array.   For the indicator we need a new array that we also need to sort downwards by using array set as series.   Let’s keep going and define what our function is. For this, MQL5 has a built-in function called IDEMA.   There must be 5 parameters defined. The first two are for the current symbol and period on the chart, and the third is for the calculation period. It is 14 in our case.   Parameter 4 is for a potential candle shift, we set it to 0.   And the last parameter defines that we are going to calculate the result based on close prices.   With copy buffer we can now fill our Array with price data according to our definition. We do that for buffer 0, starting from the current candle and store the prices for 3 candles.   Afterwards, you can now get the value for the current candle by looking at that price array and, in particular, the value for candle 0.   We can now figure out the buy signal.   When the red line is below the close price for candle 1, we want to use that as a sign to buy.   So let’s give our signal the word “buy.”   In the other case, we want to sell whenever the red line is above the close price of candle 1.   At that point, we want to give the signal variable the value “sell.”   At the end of the function, please use the return function to send the calculated value back to our main module.   The entry module is now finished. Save it right away.   Then you need to open the main file and look for the part where you need to add the entry signal.   You can do that by putting the file name for our entry signal after the include statement.   Please disable any other entry signal by putting two slashes in front of it.   When you’re done, you can compile the main module and the entry module you just made by pressing F7 or clicking the compile button.   If everything went well, you shouldn’t get any errors!   If you do, please look at the error messages and try to figure out what they mean.   On MQL5.com, you can find a list of all of these error codes.   Okay, by now you should have a working for the double exponential moving average indicator that we see on our chart. I would like to say thank you for watching this video and I will see you in the next one. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ENVELOPES ENTRY SIGNAL MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - DEMARKER OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ADVANCED MOVING AVERAGE… The post MQL5 TUTORIAL – PLATIN SYSTEM – IDEMA INDICATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – BULLS POWER OSCILLATOR

    Play Episode Listen Later Dec 3, 2022 3:08


        In this video, we are going to create an entry signal for the bolts Power Oscillator. It looks very similar to the Bears Power Oscillator that we have created before. And it’s similar to do. So let’s find out how to do it with MQL5.    This time, we’re going to figure out the Bulls power oscillator and use it to make a trading system entry signal.   The Bulls Power is shown below the candle chart, and it shows numbers that are either above or below 0.   To start, we make a new file called CheckEntry BullsPower and put it in the same directory as the other system files.   The new file will use a function called CheckEntry, and we’ll make a variable called signal that will be used to return our calculated signal at the end of the function.   We’ll also need an array to store price information for a few candles.   Now, let’s keep going and define what our oscillating function is. For this, MQL5 has a built-in function called iBullsPower.   There must be three parameters. The first two are for the current symbol and period on the chart, and the third is for the calculation period. It is 13 in our case.   Then, we use Array set as Series to sort our array starting with the current candle and going down.   Now we can use CopyBuffer to add data to our array.   We do it for the definition we just made and for buffer 0!   We want to start with the current candle 0 and copy the price data for the next three candles.   Our price array holds the result.   And because of that, you can now find the value for the current candle by looking at that price array and, in particular, the value for candle 0.   We can now figure out the buy signal.   When the Bulls power value is greater than 0, we want to use that as a sign to buy.   So let’s give our signal the word “buy.”   In the other case, we want to sell whenever the value is less than 0.   At that point, we want to give the signal variable the value “sell.”   At the end of the function, please use the return function to send the calculated value back to our main module.   The entry module is done, now. Save it right away.   Then you need to open the main file and look for the part where you need to add the entry signal.   You can do that by putting the file name for our entry signal after the include statement.   Please remove  any other entry signal by putting two slashes in front of it.   When you’re done, you can compile the main module and the entry module you just made by pressing F7 or clicking the compile button.   If everything went well, you shouldn’t get any errors, just some warnings!!   Okay, that’s it for the Bulls Power Oscillator. Smart idea to do two Oscillators that look almost exactly the same. Thank you for watching this video. I will see you in the next one.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - BEARS POWER OSCILLATOR MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – BULLS POWER OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – BEARS POWER OSCILLATOR

    Play Episode Listen Later Nov 27, 2022 3:12


        In this video, we are looking at the Bears Power Oscillator. That’s the little Oscillator here below the candle chart. So let’s find out how to create an expert advisor entry signal for this Oscillator.   This time we want to calculate the bears power oscillator and use it to create an entry signal for your trading system.   The Bears Power is shown below the candle chart and it creates values that are either above or below 0!   To get started, we create a new file called CheckEntry_BearsPower in our directory where the other system files are already stored.   The new file will use a function called CheckEntry and we create a variable called signal that will be used to return our calculated signal, at the end of the function.   And, of course, we also need an array to hold price data for a few candles.   Now let's continue and create a definition for our oscillating function. MQL5 offers an integrated function for that called iBearsPower.   Three parameters are required. The first two are for the current symbol and period on the chart, the third one is for the calculation period. In our case it is 13.   Afterwards we use Array set as Series to sort our array from the current candle downwards.   And now we can fill our array with data by using CopyBuffer.    We do it for the definition that we have created a minute ago and for buffer 0!   We want to start with the current candle 0 and copy price data for 3 candles.   The result is stored in our price array.   And that makes it possible to now get the value for the current candle by looking into that price array and especially at the value for candle 0!   Now we can calculate the buy signal.   Whenever the bears power value is above 0 we want to use it as a buy signal.   So let's assign the word buy to our signal.   In the other case, we want to sell whenever the value is below 0!   That is when we want to assign the word sell to the signal variable.   And now please use the return function to return the calculated value to our main module at the end of the function.   That's it for the entry module. Please save it now.   And afterwards you need to open the main file and look for the part where the entry signal now needs to be included.   You can do that by using the include statement followed by the file name for our entry signal.   Please outcomment any other entry signal by adding two slashes.   When you are finished, you can press F7 or click the compile button to compile the main module and the entry module you have just created!   If everything went well, you should not get any errors!   If you do, please check out the error messages and what they mean!   On MQL5.com there is a list of those error codes available!   Okay, by now, you should have a working version for the Bears Power Oscillator. I would like to say thank you for watching this video and I will see you in the next one.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - BULLS POWER OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MOMENTUM OSCILLATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – BEARS POWER OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – CHAIKIN OSCILLATOR

    Play Episode Listen Later Nov 22, 2022 3:15


        In this video, we are going to create an entry module for this oscillator here. It is called the Chaiken oscillator. So let’s find out how we can code an entry module.   The chaikin oscillator is usually used to confirm other signals, because it is an oscillator.   But in this example we will use it to generate buy and sell signals!   Let's create a new file called CheckEntry_Chaikin.mp5 in the same directory where the other files are stored.   Like we have done for other entry modules we need to create a function called CheckEntry.   The signal is later returned by this function.   And now we need a string variable and a price array!   MQL5 comes with a function called iChaikin that we can use to create our definition for the calculation.   Parameter 1 is for the current symbol and parameter 2 for the current period on our chart.   Afterwards we have two numbers!   If you open Metatrader5 and select insert, indicators, oscillators, you will learn that these values are for the fast moving average and for the slow moving average.   The standard values are 3 and 10!   The following parameter is used to define that we want to calculate the result based on Mode_EMA, that stands for exponential moving average.   And in the last parameter we have defined that the result should be calculated on the tick basis.   Now let's continue and sort the array from the current candle downwards by using array set as series.   And then we use Copy Buffer to fill our array with data!   We do it for the formerly created definition and buffer zero, starting from the current candle 0.   We want to store the values for 3 candles in our array!   Now we can calculate the values for the current candle and the one before.   We do that by looking at the values of candle 0 and candle 1 in our array.   If the current chaikin value is above 0 and the previous value was below 0, we consider that to be a buy signal and assign the word buy to our signal.   Otherwise, if the current value is below 0 and the previous value was above 0, that will be a sell signal, so we assign the word sell to our signal.   And finally we use the return function to return the calculated value to our main module.   That is it for the entry, please do not forget to save it.   Compiling is not required as it is imported into the main module.   Now let’s open the main module and find the include section.   There you can outcomment the other entry modules with two slashes and add a new include statement for the new file that we have created.   And now we need to press F7 or click on the compile button to compile both modules.   You will see some warnings, but you should not get any errors.   Okay, so far, this is it for the Chaikin oscillator. I hope the compilation process worked for you. Thank you for watching, and thank you for watching, and I will see you in the next video. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM ACCUMULATION DISTRIBUTION… MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - BEARS POWER OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – CHAIKIN OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL- SIMPLE ICCI STANDALONE EA

    Play Episode Listen Later Nov 19, 2022 7:11


    In this video we are going to create an Expert Advisor for this signal here; it’s the Commodity Channel Index, and you see that we have already opened a position, it produces buy and sell signals here on the chart. Whenever the signal is below the lower line we are going to buy and when it’s above we are going to sell. Now how can we create an Expert Advisor in MQL5 that is actually able to trade the Commodity Channel Index? To do that 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: “SimpleICCIStandaloneEA”, click on “Continue”, “Continue” and “Finish”, now you can remove everything that is above the “OnTick” function and let’s also delete the two comment lines here. First we want to include the file: “Trade.mqh”, it comes with MQL5 and it will help us to create an instance of the class “CTrade” that will be called: “trade” and we are going to use it to actually open positions later on but before we can do that we need to calculate a few things. For example the Ask price. We get that by using “SymbolInfoDouble” for the current symbol and with “SYMBOL_ASK” we will get the Ask price. “NormalizeDouble” and “_Digits” will help us to get the price with either 3 or 5 digits behind the dot depending on the currency pair. Let’s do the same for the Bid price, it’s almost exactly the same but this time we use “SYMBOL_BID”. Now we use “MqlRates” to create an array for the prices, we will call that:”PriceInfo” and we sort the array from the current candle downwards by using “ArraySetAsSeries” and we use “CopyRates” to fill our “PriceInfo” array with price data for the last candles. We will use the current symbol on the chart, the currently selected period and we will start with the prices for candle 0 (zero) – that’s the current candle – and we only need prices for 3 candles and store that result in the “PriceInfo” array. We also need to create a string for the signal that will be called: “signal” and it has no value right now because we are going to calculate that later on. We need to create another array, this time we will call it: “myPriceArray”. Well, this one was for the candle prices (PriceInfo) and the second one will be for the Expert Advisor (myPriceArray). Let’s define the Commodity Channel Index here (CCIDefinition), we are going to use the built-in: “iCCI” function for the current symbol and the current period on the chart, it will be calculated based on 14 candles – that’s also what you see if you click on: “Insert/ Indicators/ Oscillators/ Commodity Channel Index”, you see 14 candles – and our result will be calculated based on the close prices. Let’s sort the price array (myPriceArray) from the current candle downwards by using “ArraySetAsSeries” and with “CopyBuffer” we fill our price array (myPriceArray) according to the Commodity Channel Index definition (CCIDefinition) that we have created here for the first signal buffer, – that’s the line here – we start with candle 0 (zero) – that’s the current candle – and we copy the values of 3 candles and store it in our price array (myPriceArray). Finally we are able to get the value of the current candle by looking at candle 0 (zero) in our price array (myPriceArray) and the result will be stored in the variable called: ”CCIValue” and if the “CCIValue” is bigger than 100 – that would be the case whenever the blue line is above the upper dotted line, you see the 100 mark here – and if that is the case we want to sell so we assign the word: “sell” to our signal. Otherwise if the “CCIValue” is below the -100 (minus 100) line – that is the lower dotted line here – we want to buy so we assign the word: “buy” to our signal. And if the signal equals sell and “PositionsTotal” is less than 1 – with other words we wouldn’t have any open positions on the chart – we want to sell so we use “trade.Sell” to sell 10 micro lot. Otherwise if the signal equals buy and we have no open positions we want to buy so we use “trade.Buy” to buy 10 micro lot. Finally we create an output on the chart by using the “Comment” function, it will output the words: “The current signal is:” followed by the “signal” that we have calculated. Okay, that’s it so far, please click on the “Compile” button or press F7. We don’t see any errors here 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 and R, please select the “SimpleICCIStandaloneEA”, mark the visualization option here and click on start. Here we are! This is our first position, we can speed up the process a little bit and you see that it is creating buy and sell signals, we already have opened a position here and now you know how to create an Expert Advisor that is able to trade the Commodity Channel Index in MQL5 and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL BASICS - 46 SIMPLE COMMODITY CHANNEL INDEX EA MQL5 TUTORIAL BASICS - 54 SIMPLE IFORCE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE AWESOME STANDALONE EXPERT ADVISOR MQL5 TUTORIAL - SIMPLE ENVELOPES STANDALONE EXPERT ADVISOR MQL5 TUTORIAL BASICS - 49 SIMPLE WILLIAMS PERCENT RANGE EA The post MQL5 TUTORIAL- SIMPLE ICCI STANDALONE EA appeared first on MQL5 Tutorial.

    MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR

    Play Episode Listen Later Nov 13, 2022 3:47


        This colorful indicator here below the chart window is called the awesome Oscillator. We want to create an entry signal to calculate the values for our entry signals that are traded here. So let’s find out how we can do that with MQL5.   Since the Awesome indicator is an oscillator, it will be shown in a separate window below the candle chart.   To use it, we make a separate MQ5 file and put it in the same directory as the other Platin System files.   CheckEntry IAO.mq5 is the name of the file, and it only has one function called CheckEntry.   The buy and sell signals for our system are worked out by this function.   We start with a string variable called signal, but we don’t give it a value right away because we’ll figure that out later.   The next thing we do is make an array. We use the “double” data type because it can also be used with “floating point” numbers.   Then, we use the function iAO that comes with MQL5 to create a definition for the Awesome Oscillator signal.   And we want to do that for the current symbol on the chart and the period that is currently selected on that chart.   No further parameters are required.   Now we use Array Set as Series for our IAO Array to sort it from the current candle downwards.   Afterwards we can fill our IAO Array according to the definition that we have done above.   We do it for buffer 0, starting from candle 0 for 3 candles and store the values in our price array.   That makes it possible to calculate the current IAO Value by looking at candle 0 in our array.   With normalize double, we make sure to format the output with 6 digits behind the dot, as this is how the value also looks like when you add the oscillator manually to your chart.   Now, let's continue with the calculation for the signal.   If the current value is above 0 we want to buy, so we assign the word buy to our signal.   And when the current value is below 0, we want to sell so we assign the word sell to the signal.   The last part is to give back the calculated value by using the return function and we also need to save the file.   Compiling will be done in the main file, so please open it and look for the include statements that are already contained in the source code.   There we will use two slashes to outcomment the other entry signals and add another line to include the new file called CheckEntry_ IAO.mq5.   Afterwards we can click the compile button or simply press the F7 key to get both files compiled.   A few warnings are expected, but you should not see any further error codes.   Okay, by now, you should have a compiled version for this little oscillator here. You see that it’s creating lots of trades. And I would like to say thank you for watching this video, and I will see you in the next one.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MOMENTUM OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - RELATIVE STRENGTH INDICATOR The post MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – STOCHASTIC OSCILLATOR

    Play Episode Listen Later Nov 10, 2022 4:57


        In this video, we want to check out this Oscillator here. It is called the Stochastic oscillator, and it is very popular. So let’s find out how we can create an entry signal for this one with MQL5.   In this video, we’re going to make an entry signal for this little oscillator that an expert advisor can use. It’s called the “Stochastic oscillator,” and a lot of people use it. So let’s find out how MQL5 can help us do that.   The Stochastic oscillator is shown in a separate window below the candle chart.   It has two lines and a scale.   Most of the time, oscillators are used to filter out signals, but they can also be used to make entry signals, which is what we’ll do here.   To use it, we make a separate MQ5 file and put it in the same folder as the other Platin System files.   The file is called CheckEntry Stochastic.mq5, and it has only one function called CheckEntry.   It will figure out what our entry signal is and send that information back to the main module.   We want to make a string variable for the calculated signal, but we won’t give it a value yet because that will be worked out later.   Now we need two double-type arrays to hold the different prices.   The first one is called the K-Array and the second one is called the D-Array.   We sort both arrays from the current candle downwards by using Array set as Series.   MQL5 comes with a function called iStochastic which we can use to create a definition for our oscillator.   We need to pass a few parameters. The first parameter is for the symbol on the chart. The second parameter is for the period on the chart.   Parameters 3, 4 and 5 are the standard values for the Stochastic oscillator to define the so-called K-period, the D-period and the slowing. You will also see these values when you drag the Stochastic indicator onto one of your charts.   In the last two parameters, we define that we want to use MODE_SMA which stands for the simple moving average mode and we want to calculate the result based on the low and high prices.   With CopyBuffer we fill both arrays with data and we do that for buffer 0 and buffer 1. In both cases from the current candle 0 and for 3 candles.   Let's continue and calculate the value for the current candle by looking at the value of candle 0 in both arrays.   Afterwards we do the same for the candle before by looking at the values for candle 1 in both arrays.   To calculate the buy signal, we check for a crossover.   So if the K-value and the D-value for candle 0 are below 20, we want to know if the K-value is now above the D-value and if it was below for the candle before.   That would be a buy signal and that is when we assign the word buy to our signal.   Otherwise, if the K-value and the D-value for candle 0 are above 80 we want to know if the K-value is now below the D-value and if it was higher for the candle before.   That would be a sell signal and that is when we assign the word sell to our signal.   At the end of the function we use the return command to return the signal to the main module.   Please remember to save the file.   You don’t have to compile it. Just save it and go back to the main module, where the OnTick function is.   There, you must add the new file to the include section. This can be done with the help of the include statement.   Please use two slashes to outcomment any other entry signals and press F7 or click the Compile button to compile both the main module and the new entry file you just made.   Okay, if everything worked out as it should, you should now have a working version for the Stochastic Oscillator. Please note that this one will not create so many signals, because it will only create signals when we see a cross over here. That’s it for now. Thank you for watching, and I will see you in the next video.   Not sure what to do? Click on the automated trading assistant below MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - MACD OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - BEARS POWER OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - BULLS POWER OSCILLATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – STOCHASTIC OSCILLATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE AMA STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Nov 6, 2022 7:13


    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. And if the signal equals sell and “PositionsTotal” is below 1 – that means we don't have any open positions – 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. Finally we use the “Comment” function to create a chart output that will say: “The current signal is:” followed by the calculated signal. So far so good, please click on the “Compile” button or press F7. I don't have any errors and I don't have any warnings so now we can click here or press F4 to go back to Metatrader. In Metatrader we click on: “View/ Strategy Tester” or press CTRL and R, here we select the: “SimpleAMAStandaloneEA.ex5” file, enable the visualization mode here and start a test. …and here we are! Our Expert Advisor is creating buy and sell signals, we already have an open position here and in this little video you learned how to code an Expert Advisor that is actually going to trade the Adaptive Moving Average Indicator and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - 131 STANDALONE EMA MACD EXPERT ADVISOR MQL5 TUTORIAL BASICS - 72 SIMPLE TRIPPLE EMA MQL5 TUTORIAL - SIMPLE SIGNAL STACKING MQL5 TUTORIAL BASICS - 43 SIMPLE IOSMA EA MQL5 TUTORIAL BASICS - 52 SIMPLE EXTERNAL CANDLE NUMBER EA The post MQL5 TUTORIAL – SIMPLE AMA STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – PARABOLIC SAR INDICATOR

    Play Episode Listen Later Nov 3, 2022 4:29


        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.   Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - BOLLINGER BANDS ENTRY SIGNAL MQL5 TUTORIAL - PLATIN SYSTEM - MOMENTUM OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - BEARS POWER OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ENVELOPES ENTRY SIGNAL MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR The post MQL5 TUTORIAL – PLATIN SYSTEM – PARABOLIC SAR INDICATOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – SIMPLE AWESOME STANDALONE EXPERT ADVISOR

    Play Episode Listen Later Oct 30, 2022 6:28


    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 calculated “signal” directly on our chart. Okay, if you’re done you can click on the “Compile” button here or press F7, that should work without any errors and in that case you can click on the little button here or press F4 to go back to Metatrader and in Metatrader we click on: “View/ Strategy Tester” or press CTRL and R, please select the new file: “SimpleAwesomeStandaloneEA”, let’s also mark the visualization option here and start a test. …and here we are, our Expert Advisor is working, actually we have opened the first automated trade and now you know how to code the Awesome Oscillator Standalone Expert Advisor and you have coded it yourself with a few lines of MQL5 code. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - SIMPLE STOCHASTIC STANDALONE EXPERT ADVISOR MQL5 TUTORIAL- SIMPLE ICCI STANDALONE EA MQL5 TUTORIAL - SIMPLE MACD STANDALONE EXPERT ADVISOR MQL5-TUTORIAL-PLATIN-SYSTEM-THE-AWESOME-OSCILLATOR MQL5 TUTORIAL BASICS - 46 SIMPLE COMMODITY CHANNEL INDEX EA The post MQL5 TUTORIAL – SIMPLE AWESOME STANDALONE EXPERT ADVISOR appeared first on MQL5 Tutorial.

    MQL5 TUTORIAL – PLATIN SYSTEM – RELATIVE VIGOR INDEX

    Play Episode Listen Later Oct 27, 2022 3:52


        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. Not sure what to do? Click on the automated trading assistant below MQL5 TUTORIAL - PLATIN SYSTEM - RELATIVE STRENGTH INDICATOR MQL5 TUTORIAL - PLATIN SYSTEM - MOMENTUM OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - ACCELERATOR OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM - STOCHASTIC OSCILLATOR MQL5 TUTORIAL - PLATIN SYSTEM ACCUMULATION DISTRIBUTION… The post MQL5 TUTORIAL – PLATIN SYSTEM – RELATIVE VIGOR INDEX appeared first on MQL5 Tutorial.

    Claim MQL5 Tutorial

    In order to claim this podcast we'll send an email to with a verification link. Simply click the link and you will be able to edit tags, request a refresh, and other features to take control of your podcast page!

    Claim Cancel