MQL4TUTORIAL.COM

MQL4TUTORIAL.COM

By MQL4TUTORIAL.COMBusinessInvesting
Download on the App Store

MQL4TUTORIAL.COM episodes

  • MQL4 TUTORIAL – PLATIN SYSTEM – WILLAMS PERCENT RANGE ENTRY SIGNAL

    [This post contains video, click to play]

     

    In this video, we want to create an Expert Advisor entry signal for this little Oscillator here. This is the volumes percent range oscillator. So let’s see how we we can create an entry module for our Platin System with MQL4. The Williams Percent Range Indicator is actually an oscillator signal, therefore it will be shown in a separate oscillator window below the candle chart. To create an entry signal for our Platin System we need to create a file called CheckEntry_WPR.mq4 in the same directory as our other files.

     

    Actually you can use this entry signal file also for your own, self coded system or for the RobotTradingSystem. The file has one function called CheckEntry and we use it to calculate the signal for our main module. To do that, we create a string variable called signal but we are not going to assign a value right away, because that will be calculated in the following steps. MQL4 comes with an included function for that calculation and the name of the function is iWPR. It needs a few parameters that we have to pass. The first parameter is for the current symbol on the chart.

     

    The second one is for the currently selected period on that chart. The third parameter is used for the number of candles that we are using to calculate our result. And the last parameter is for a shift value. We don’t need that, so we set it to 0. If you open an empty chart in Metatrader and click on Insert, Indicators, Oscillators and pick the Williams Percent Range oscillator, you will see that the default value for the period is also 14. Please confirm that setting with Okay, right click into the chart and save the template as tester.tpl. Tester.tpl is the template that is used in the strategy tester to actually see the entry signal. But back to the entry signal module.

     

    Now that we have calculated the WPR value, we can check if the value is below -80. If this is the case, we consider that to be a buy signal, so we assign the word buy to our signal. In the other case, if the signal is below -20, that would mean we have a sell signal and then we assign the word sell to our signal. Finally we use the return statement to return the signal to our main module. Please save the file for the entry signal, but you don’t need to compile it. It will be compiled with the main module when you have changed the entry signal there. To do that, please open the main module, and modify the include statement for your entry signal below the import section.

     

    You can outcomment your current module with two slashes. It will then become gray. Please enable the toolbar and click on the compile button to compile the main module and your entry signal at once. You shouldn’t get any errors. If you have errors, please go to our website and check the shop for precompiled source codes. Okay. By now, you should have a working Williams Percent Range indicator entry file that you can use in the Platinum system.

     

    Or you can use it in your own system. If you have any problems, please check out our website. Maybe even the premium course might be interesting for you. For now, I say thank you for listening, and I will see you in the next video.

    5 min
  • MQL4 TUTORIAL – SIMPLE SMA STANDALONE EXPERT ADVISOR

    [This post contains video, click to play]

    In this video we are going to talk about a standalone Expert Advisor that is going to actually trade. Whenever the price is below this yellow line here – this is a Moving Average – we have already made a sell trade and in this video we are going to find out how to do a standalone Expert Advisor that actually trades in MQL4.

    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” (Next), I will call this version: “SimpleStandaloneSMA”, click on “Continue” (Next), “Continue” (Next) and “Finish”.
    Now you can remove everything above the “OnTick” function and let’s also delete the two comment lines here.
    Okay. Let’s start by creating a string variable for the signal, that variable will be also called: “signal” and we don’t assign a value here because we are going to calculate it later on.
    To calculate it we use the built-in “iMA” function that comes with MQL 4 and it will calculate the Moving Average for the current symbol on the chart and the currently selected period on that chart – for example I’m on the 1-minute chart right now – we want to calculate the Moving Average for 20 candles, I don’t want to use a shift value, I could move the Moving Average drawing to the right or to the left but we are going to use a zero (0) shift value here.
    “MODE_SMA” will calculate the Simple Moving Average, “PRICE_CLOSE” we’ll use the close price for the calculation and the last value here is candle 0 (zero) – that’s the current candle – I could also calculate the Moving Average based on one of the other candles here but in this simple version we are going to use the current candle.
    And if the Moving Average is below the current price – so if my Moving Average (MyMovingAverage) is below the close price for candle 0 (zero)…
    …and please notice that close for candle 0 (zero) actually doesn’t exist because candle 0 (zero) is always the candle that is just in development and close price for candle 0 (zero) gives you the current price here and when that price is bigger than the Moving Average value we want to set the signal variable to buy so we assign the word: “buy” to our signal.
    And guess what? If the Moving Average is above the current price, so if my Moving Average (MyMovingAverage) is bigger than the current price we want to set the signal variable to sell so we assign the word: ”sell” to our signal.
    Now let’s actually buy something!
    When the signal equals buy and “OrdersTotal” equals 0 (zero) – and that is true when we have no open orders – we use the “OrderSend” command to buy 10 micro lot and the take profit value is 150 points above the Ask price.
    If you are interested in the “OrderSend” command just mark it here and press F1 and you will see how it works, but let’s continue with the selling part!
    To sell 10 micro lot we check if the signal equals “sell” and if we have no open orders and in that case we use the “OrderSend” statement to sell 10 micro lot and this time the take profit value will be 150 points below the Bid price. Please notice that we use “OP_BUY” to buy something and “OP_SELL” to sell something.
    That’s almost it.
    In the last step we use the “Comment” function to output the words: “The current signal is:” and the calculated signal on our chart.
    Okay, so far so good, please click on the “Compile” button or press F7 on your keyboard, you should see no errors and we have 2 warnings because we could use the return value for “OrderSend” but for this simple example everything is okay, we don’t use that so now please click here or press F4 to go back to Metatrader.
    In Metatrader we click on “View/ Strategy Tester” or press CTRL and R, here in the Strategy Tester please select the “SimpleStandaloneSMA.ex4” file, mark the option for the visual mode and start your test.
    …and here is our little Expert Advisor at work, we have already made a sell trade because the price is below the Moving Average line here and now you know how to create a standalone Expert Advisor to automatically trade a Moving Average and you have coded it yourself with a few lines of MQL4 code.

    Download “MQL4 TUTORIAL - SIMPLE STANDALONE SMA EXPERT ADVISOR” SimpleStandaloneSMA.txt – Downloaded 3615 times
    – 996.00 B
    6 min
  • MQL4 TUTORIAL – SIMPLE COMMODITY CHANNEL INDEX

    [This post contains video, click to play]

    In this video we are going to trade the Commodity Channel Index, that’s the Indicator right here; you see the two dotted lines and whenever the line here crosses the upper dotted line we consider that to be a sell signal and when it crosses the lower dotted line that would be a buy signal.

    In this video we are going to find out how to automatically calculate this signal with a few lines of MQL4 code.
    To do that please click on the little button here 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: “SimpleCommodityChannelIndex”, click on “Continue”, “Continue” and “Finish” and now you can remove everything above the “OnTick” function and the two comment lines here.
    Let’s start with a string variable for the signal, that variable will also be called: “signal” – we don’t assign a value because we are going to calculate that later on.
    Let’s define our indicator that is done by using the “iCCI” function that comes with MQL4 and if you mark it and hit the F1 key you will see it takes a few parameters. The first parameter is for the symbol – that’s actually the currency pair on your chart –, the second one is for the time frame, in our case we use the 1 minute time frame – another time frame could be 5 minutes or 15 minutes and so on –, the third parameter is for the averaging period, that’s actually the period we use to calculate the signal and if you click on “Insert Indicators Custom CCI” you will see that the CCI period is 14, so that’s what we are using here followed by a typical price. You could also use a close or an open price, the highest or the lowest price, and the last parameter here is for the shift. You could use a shift value to move the Indicator window to right or to the left. We are not going to use it so our last parameter will be 0.
    Now that we know the value we want to find out if it is above 100, so if the “ICCIValue” we have defined here is greater than 100 – that would be the case when it’s above the dotted line here, because this is the 100-plus line –, we consider our currency pair to be oversold so we assign the word: “sell” to our signal.
    In the other case if our value is below -100, so if our “ICCIValue” is below -100 – that would be the case when the line is below the dotted line here, because the lower line is the minus 100 line – in that case we consider it to be a buy signal so we assign the word: “buy” to our signal.
    In the last step we create a chart output that is done by using the “Comment” function and we want to output the word: “Signal:” followed by the calculated signal (signal) and in a new line we want to have the output: “ICCI Value:” followed by the current ICC I value (ICCIValue).
    Okay. Please don’t forget the closing bracket and when you are done you can click on the “Compile” button here or press F7 on your keyboard and now you should see an output like this. We have compiled it without any errors and without any warnings and in that case you can click on a little button here or press F4 to go back to Metatrader and in Metatrader we use a little trick; please click on “Insert Indicators Custom CCI” we will go with the default values here so please click on “OK”.
    Now you should see the little window with the Indicator below the candles and now we right-click in our chart and select: “Template Save Template” and save it as: “tester.tpl” because this is the template that our strategy tester is going to use for the next back test.
    If you don’t see the strategy tester panel you can click on “View Strategy Tester” or press CTRL and R, let’s select the simple “SimpleCommodityChannelIndex.ex4” file we have just created enable the visual mode here, pick a currency pair and start our test.
    So let’s speed up the test and now you can see buy and sell signals appearing on your chart so our little Expert Advisor works and now you know how to code the Commodity Channel Index Indicator in MQL4 and you have coded it yourself with a few lines of MQL4 code.

    Download “MQL4 TUTORIAL - SIMPLE COMMODITY CHANNEL INDEX” SimpleICCI.txt – Downloaded 1502 times – 911.00 B
    6 min
  • MQL4 TUTORIAL – FIND REMOVE AND FIX CORRUPTED BACKTESTING DATA

    [This post contains video, click to play]

    In this video, I wanted to talk about back-testing.

    This is an automated trading system. Its trading the year 2016 right now, lets speed it up a little bit and you can see that we are making progress here. We also would like to back-test the whole year 2017, so you see that the Expert Advisor is running, lets stop the test here and we change the year to 2017 and start another test.
    It does work somehow and now it’s finished but the first trade started in November 2017!
    In this case we made a loss of nearly 300 Dollars; here is the complete report; just a single trade and a big loss, something is wrong here, but what?
    Let’s slow down the speed here and stat a new test, and now you see that we have a strange change from December to November here.
    Now what is the cause?
    Actually Metatrader 4 is going to use historical data. When you click on “Tools/ History Center” or press the F2 key you will see that we have data for each and every minute here, now let’s get down here and here is the problem! This is November 2017 and right below we have December 2016! So, obviously we have corrupted historical data here and now we want to fix that.
    The best way is to mark the first position in the “History Center”, please make sure that you have selected the 1 minute bars, now scroll down all the way, hit the shift key and mark the last entry. Now we have selected all the records and we click on the delete button. This takes a few seconds, we have still two entries here; but these are current entries from today. Let’s change to the 5 minutes data, do the same again, delete this data for 5 minutes and now I am going to do it for each time frame in the “History Center” because I want to avoid gaps that might occur just from corrupted data that might be in any of the other time frames. Sometimes you have to wait a little while or you need to start over. Mark it again, but the higher the time frame the less data you have to mark and delete.
    Eventually we have reached the monthly data and now we are done. There are a few websites where you can download historical data; I like the histdata.com website because it’s easy and free. Here you will find a “zip” file with the complete year 2017, these are 1 minute bar quotes, so let’s download that file, it’s about 3 Mega Bites and when you open it you will find the “csv” file that contains all the necessary data for the whole year, let’s copy that.
    This is my folder for history data and in the “History Center” I select 1 minute, click on “import” and now I select the file we have downloaded, click on “open” and here is all the data we need, but please make sure that you don’t mark “Use selected only” because that would prevent you from importing all the data. So, let’s click on “OK”, now we see the complete year 2017 in the “History Center”, so we can close it.
    When we stop and restart our back-test it now starts in January. We have already several results here, so now you know how to find corrupted history data, where you can download new data, you know how to import it into the “History Center”.

    5 min
  • MQL4 TUTORIAL – HOW TO GET THE LAST ERROR
      In this video we are going to talk about common backtesting errors and how to find them. This is an Expert Advisor, but it doesn’t show anything and it doesn’t trade. So the first thing you need to check is the journal tab here. And here you might see an error message like this one: order send error 131. Now, what does that actually mean? Let’s pause the strategy tester here.   Right click on one of the error messages and select Copy. Now go to Google and paste the text here. I will remove the currency pair and the time and date stamps here. So now it says MQL4 order send error 131. Now you can press Enter. And you should see this one: error codes appendixes MQL4 tutorial.   And when you click on the link, you will see what each and every code of these errors mean. In our case it was 131. That’s an indicator for an invalid trade volume. Another very common error is error 138 for broker requotes. Let’s change the slippage for our trade from three to zero.   Recompile the code for a simple buy trade. I have called this Expert Advisor MQL4 errors because I wanted to show you how to create errors. Because that might help you to find them. Right now we don’t get any errors here. So let’s set this one to minus one. Now click on compile. And you can compile it without any errors and any warnings because syntactically everything is correct.   Now let’s start a new test here. And this time it says order sent error 4051. Let’s see if we can find this one: 4051 means invalid function parameter value. So let’s get back to three pips for the slippage. Let’s try a value of Ask plus 100 points for the stop loss, compile the code.   And once again you don’t see any errors here. But when you restart your Expert Advisor test, you see order send error 130. And 130 stands for invalid stops. Let’s fix this error and set the take profit value to Ask minus ten times point. Once again you can compile everything, but when you start a new test you will see other send error 130.   Well, we intentionally created all the errors here, but you might even experience order errors just because you change a setting. Everything is all right here. Let’s compile it, restart a test and you should see that it works. But when you stop the test and change the spread value here to 100, you will see, after you have clicked on start, that the order send error 130 remains. From time to time you may ask yourself: what is going wrong here?   So there is a way to output the last error directly here on the chart. Let’s stop the test here and change our little test expert advisor here. We are going to use the comment function to output the text “the last error was” and we use the function get last error, because that will return the contents of the system variable last error. And in this last error, you will find all the error codes here. So let’s check it out.   Just recompile the code, click the little button here, or press F4 on your keyboard. And when I start the expert advisor, it says the last error was 130. If I readjust the spread here and start another test, the output is the last error was zero. Okay, now, you know how to find errors in MQL4, and you know how to create an output directly on your chart. And I would suggest to use this simple expert advisor here and change a few things.   And when you restart your expert advisor, you should get the output of the error code directly on the chart.   Not sure what to do? Click on the automated trading assistant below MQL4 TUTORIAL BASICS – 120 SIMPLE RSI BUY STOP     In this video we are going to create… MQL4 TUTORIAL BASICS - 122 SIMPLE AVERAGE TRUE RANGE…   In this video we are going to use the… MQL4 TUTORIAL BASICS - 123 HOW TO FIND ERRORS IN BIG… In this video we are going to look for errors.… MQL4 TUTORIAL BASICS - 112 SIMPLE BUY PERCENTAGE RISK   In this video, we are going to create an… MQL4-TUTORIAL-PLATIN-SYSTEM-MACD-OSCILLATOR       In this video, we want to calculate… The post MQL4 TUTORIAL – HOW TO GET THE LAST ERROR appeared first on MQL4TUTORIAL.COM.
    6 min
  • MQL4 TUTORIAL – SIMPLE CUSTOM TIME FUNCTION
    In this video we are going to create a little custom function to calculate the local time. You see that we have an output for the current date that is traded here in the Strategy Tester and this is the current time and now we are going to create a custom function in MQL4 to calculate and output the time in this way. To do that please click 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 file: “SimpleCustomTimeFunction”, click on “Continue”, “Continue” and “Finish” and now you can delete everything above the “OnTick” function and let’s also delete the two comment lines here. We start with a string that will be called: “myTime” it’s a string variable for the custom time that we are going to calculate and we are going to create a custom function that will be called: “GetTime” and to calculate “myTime” I just try to call the function: “GetTime” here. If I click on the “Compile” button now you will see that “GetTime” function is not defined so this is definitely nothing that comes with MQL 4 and now we are going to create it. It should return a string value, the name is: “GetTime” and as soon as I add two curly brackets and recompile the code the error is gone. Now let’s add some logic to the “GetTime” function that we have created right now. I would like to output the time with seconds like we see it here: 17:55 means 5 minutes to 6:00 p.m. and to calculate the time we use a function that is called: “TimeLocal” and we want the output for the date; this is the first part here with the date (TIME_DATE), this is the pipe symbol and here is the second parameter for the time with seconds (TIME_SECONDS) – that’s the second part here – and we use time to string (TimeToStr) to convert the time from a datetime variable to a string. Let’s mark “TimeToStr” press F1 and we see; okay, it converts the value of the time and seconds that have passed since January the 1st in 1970 into a string that has this format here and now that the calculation is done we want to return the calculated time to the main function that is done by using “return” for our string variable that we have calculated here, so everything within the “GetTime” function will be calculated here and the result is assigned to the variable: “myTime” so if we add the “Comment” function here for “myTime” it should create the desired chart output for the time we have calculated. Now please click on the “Compile” button or press F7 that should work without any errors and if that is the case please click here or press F4 to go back to Metatrader and in Metatrader we click on: “View/ Strategy Tester” or press CTRL + R that will bring up the Strategy Tester panel here and here you want to select the new file: “SimpleCustomTimeFunction”, please enable the visual mode here and start your test. …and here we are. Our Expert Advisor is working and now you know how to create a custom time function for Metatrader 4 and you have coded it yourself with a few lines of MQL4 code.
    5 min
  • MQL4 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – DOWNLOAD THE SYSTEM BELOW
      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   Alright,let’s start with the beginning. There is nothing like the trading experiment we are doing in 2024 that I have ever done before. I spent several weeks ago viewing Netflix movies while lying in bed due to a severe illness. These included advertising-filled movies. One such advertisement that I kept seeing featured a woman receiving face cream for Christmas. In order to improve her skin, she also showed how to use the cream with pineapple. I had no interest in this at all, and I would never use face cream with pineapple, no matter how many times I saw this advertisement. Why am I revealing this to you? Relevance is key! I will not be able to sell something irrelevant if I offer it.   The same holds true with pineapple facial cream. If something is simply irrelevant, it makes no difference how hard I try to persuade someone. What kind of advertising technology is employed is irrelevant, in my opinion. No matter how tempting the advertisement is, there isn’t much anyone can do if something doesn’t interest me. Generally speaking, I search for deals—solutions that offer me greater value than they do cost. Stated differently, you receive something valuable for less than what you would be willing to spend. We’re doing something different this year because of this. Many businesses, in my opinion, are stuck in the middle of attempting to get everyone on the earth to buy their products at a time when everyone is trying to shout louder and louder. Personally, I don’t like being taken advantage of, and I have never made a big deal out of my trading methods. I am aware that many in the financial industry flash large wads of cash from a Dubai skyscraper or show off their Ferrari, but I think the majority of prospective customers are quick to sniff out such questionable tactics.   I therefore searched for a long time for a subtle approach to persuade individuals who were similar to me, but still offering something that I would myself purchase. I came across Frank Kern, who teaches a really amazing tactic. It is said to be the oldest tactic in his books and involves persuading someone that you can assist them by actually being of assistance to them. Because automated trading is rather simple, we are currently using a demo account and will continue to trade using a demo system in 2024 in an effort to improve performance. I think you want better outcomes, and based on the past ten years, I’ve known that 10 to 15 percent of viewers of these videos are looking to purchase the appropriate solution. That does not imply that you must purchase it personally, but I think the secret to success is probability.   Given my statistics, it is quite probable that 10 to 15 percent of visitors will make a purchase from me in the future because they are certain that what I am providing is the precise answer they have been searching for. For demo accounts, the Robot Trading System can now be downloaded for free. The link is provided below this video. We will examine how to configure this system in Meta Trader in the upcoming videos in order to get long-term success. In any case, I think you should trade on a demo account for the first few weeks or months before using the strategy on a "cent account." Thus, this tactic works nicely. Additionally, I believe it will enable me and you to perform better in 2024. That concludes the video. Thank you for watching, and I’ll see you in the next one. ​ Not sure what to do? Click on the automated trading assistant below MQL4 TUTORIAL - LIVE TRADING EXPERIMENT 2024 - SETUP… https://youtu.be/Q6oLd01iGpc   README Documentation (updated often): https://bit.ly/41FPceY   In this… MQL4 TUTORIAL - PLATIN SYSTEM - HOW TO CALCULATE…   An automatic trading system works the same way as… MQL4 TUTORIAL - LIVE TRADING EXPERIMENT 2024 -… https://youtu.be/0jN6lTZNWyo   README Documentation (updated often): https://bit.ly/41FPceY   We talked… MQL4 TUTORIAL - LIVE TRADING EXPERIMENT 2024 -… https://youtu.be/pXFDhd1chw8       After installing MX Linux from scratch… MQL4-TUTORIAL-PLATIN-SYSTEM-ACCUMULATION-DISTRIBUTIO…       In this video, we are going to… MQL4 TUTORIAL 98 - HOW TO CLONE YOUR MQL4 SYSTEM   In this video, I would like to talk about… MQL4 TUTORIAL - THE GREAT LIVE TRADING EXPERIMENT… https://www.youtube.com/watch?v=LMVYH7Q2kZw   20240101: DOWNLOAD 28 result videos for this system https://bit.ly/41OIpzK… MQL4 TUTORIAL - 99 NEW LIVE CROWD ALGO TRADING SYSTEM   In this video, I would like to talk about… MQL4 TUTORIAL ENGLISH - SETUP YOUR OWN ADVANCED STATISTICS   The topic of this video is putting statistics on… MQL4 Tutorial - How to get more advanced live…   TO THE STATISTICS   You can now evaluate and… The post MQL4 TUTORIAL – LIVE TRADING EXPERIMENT 2024 – DOWNLOAD THE SYSTEM BELOW appeared first on MQL4TUTORIAL.COM.
    0 min
  • MQL4 TUTORIAL – THE GREAT LIVE TRADING EXPERIMENT 2024 (you can join)
      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 describes a large-scale trading experiment that I hope to carry out with you. It’s January 1, 2024, and I’ve spent the day testing strategies for all the major currency pairings that I trade personally for this system here, trading through the whole year 2023. It’s just before 4 o’clock PM. I’ll also put these videos online so you can watch them for yourself. However, the main experiment here is that I want to work with you and other people in 2024 to improve this system. For this reason, starting in January 2024, I will be providing a demo account with an infinite version of the Robot Trading System. This implies that anything I do is yours to do with a demo account. It will also cover how to set up, modify, and enhance such a system throughout the year to ensure that you have a respectable outcome at the end of the year. I will also trade this method on a demo account at first. Even if you have never dealt with automatic trading before or if you would prefer to check over the entire thing before participating, we will also talk about and share some other resources that could be helpful. Both capital and prior expertise are not prerequisites. All you really need is a computer that was produced within the previous ten years. You require a demo account. You can use Metaquotes or other companies’ demo accounts for free, and you can use Metatrader five—which is also available for free—to do strategy testing similar to the ones you see here. On an account with a €10,000 deposit, we would have made a net profit of €1,642 this time. Why are we using a demo account for all of this activity? Few people, in fact, are prepared and eager to put in the time necessary to see genuine trading outcomes on a demo account before trading real money on a real money account. And declines like this occur in practically every trading session. And at just this moment, that causes people to close their accounts. For that’s where the biggest fear lies. But with a demo account, you don’t need to be scared. Additionally, you are free to swap at any moment as soon as you decide the system is sufficient for you. However, we have already conducted such tests, and I would like to begin 2024 in the same manner. Since nothing, in my opinion, can truly replace the information you have acquired on your own. And you have a lot to gain and not much to lose in this situation, in my opinion. This concludes the introduction video. I hope you have a wonderful new year. Over the next several days, you will receive new videos, additional information, and a download link for the version of this system that you may use on your own demo account for free. I’ve turned on a couple more Robot Trading System parameters here if you’re already a customer. This implies that more exact control over the system is now possible. I’ll see you in the upcoming video if you appreciate the outcomes shown here. I sincerely appreciate you seeing. And in the following video, we will continue. Thank you for watching this one. ​ ​ Not sure what to do? Click on the automated trading assistant below MQL4 TUTORIAL BASICS - 130 WHY MASSTESTING IS A GAME CHANGER   In this video, I would like to show you… MQL4 TUTORIAL - 197 DAYS - REAL TRADING RESULTS WITH MQL5   This video shows how 197 days of real trading… LEARN MQL4 TUTORIAL BASICS - LEVEL 1C BUILD YOUR OWN… Our new documentation series on setting up your own Algo… MQL4 TUTORIAL - 131 STANDALONE EMA MACD EXPERT ADVISOR   In this video we are going to create an… MQL4-TUTORIAL-PLATIN-SYSTEM-ACCUMULATION-DISTRIBUTIO…       In this video, we are going to… MQL4 TUTORIAL ENGLISH - 3 FATAL ERRORS THAT CAUSE…   In this video we will take a look at… MQL4 TUTORIAL - 101 WHAT HARDWARE FOR ALGORITHMIC TRADING   In this video, I would like to talk about… MQL4-TUTORIAL-PLATIN-SYSTEM-MACD-OSCILLATOR       In this video, we want to calculate… MQL4 TUTORIAL - LIVE TRADING EXPERIMENT 2024 - FIRST… https://youtu.be/OP3FTa3Rgvw   README Documentation (updated often): https://bit.ly/41FPceY   We linked… LEARN MQL4 TUTORIAL BASICS - LEVEL 1B BUILD YOUR OWN…   Our new documentation series on setting up your own… The post MQL4 TUTORIAL – THE GREAT LIVE TRADING EXPERIMENT 2024 (you can join) appeared first on MQL4TUTORIAL.COM.
    0 min
  • MQL4 TUTORIAL – SIMPLE BOLLINGER BANDS EXPERT ADVISOR
    In this video, we are going to talk about an Expert Advisor that can tell you if you should buy or sell based on the Bollinger Bands indicator. The Bollinger Bands indicator has three bands. This is the lower band. This is the middle band, and this is the upper band. Whenever a candle closes above the upper band and reenters into the bands this is a signal for a sell trade. In the other case when the candle closes below the lower band and you see a reentry from below this is a buy signal. Usually you won’t see the Bollinger Bands in your back-testing and to change this you can insert the Bollinger Bands indicator, we are going to use the period of 20 candles and deviation value of 2 because that is the standard when you click reset. Now click on ok. I will change the properties here because I like the bands to have the red color. No I right click on the chart, click on Template/Save Template. I will call this one: Bollinger Bands.tpl. Tpl stands for Template. Now let’s save this and when you start a new back-test you simply need to right click the chart, select template, Bollinger Bands and here we are. Now we are going to create an Expert Advisor that can calculate Bollinger Bands entry signals. To do that please click on the little button here or press F4 in your Metatrader and now you should see Metaeditor and here you want to click on File/New/Expert Advisor (template) from template. Continue (Next). I’ll call this one Simple Bollinger Bands. Continue (Next), Continue (Next), and Finish, and now you can delete everything above the OnTick() function and the two comment lines here. Now let’s create an empty string for the signal. I’ll call it signal and it has no value here, and to calculate the lower Bollinger Band we use the function iBands. iBands is a built-in function of MQL4 and it takes a few parameters. The first one is _Symbol; that’s the symbol on the chart, the second parameter is _Period; that’s the currently selected period on the chart, like the minute or the hour chart. We will use 20 candles and the deviation of 2 because that is what you see when you click on the Bollinger Bands properties. Period 20 candles, deviation 2, we have no shift and we apply it on the close price so the parameter for the shift is 0, and we use: PRICE_CLOSE for the close price and because this is the lower Bollinger Band we use MODE_LOWER and it will be calculated for candle 1. To calculate the upper Bollinger Band, you basically do the same but this time we use MODE_UPPER, everything else is like in this line. Candle 1 is the candle before the current candle, now when this candle isn’t finished this would be candle 1, and this would be candle 2. To calculate the value for candle 2 we repeat those two lines here and now the only thing we need to change in the two new lines is the last parameter for candle 2. Let’s calculate a buy signal. Now if the Ask price is above the close price of the last candle; that’s candle[1] and if the close price for candle[2] was below the lower band. That’s close 2 is below the value of the previous lower Bollinger Band and if the close price for candle[1] is above the lower band so that’s close 1 is greater than lower Bollinger Band that would be a signal to buy. In the other case if the price is below the last close so if Bid is below close 1 and if close 2 was above the upper band so close 2 is above previous upper Bollinger Band and close 1 is below the upper band so the close price for candle[1] is now below the upper Bollinger Band that would be a crossing like here and that would be a sell signal so we assign the word: sell to our signal. In the last step, we want to create a chart output so we use the Comment function from MQL4 to output the word: Signal, followed by the signal in the upper left corner of the chart. So, whenever we see a reentry here it will tell us that we have to buy and when the price was above the upper band and we have a reentry it will tell us that we have a signal to ...
    8 min
  • MQL4 TUTORIAL – SIMPLE SAR EXPERT ADVISOR
    In this video we are going to create an Expert Advisor that uses the parabolic SAR indicator you see to create buy or sell signals here. Whenever these little dots here are below the current price, that would be a buy signal like right now, and when the direction changes like here and the dots appear above the price, that’s a sell signal. Now how can we create an Expert Advisor that is able to produce buy and sell signals based on this indicator here? To do that please click on the little button over here or press F4 in your Metatrader. Now you should see the Metaeditor window here. Here you want to click on “File/ New/ Expert Advisor (template)” from template. Continue. I will call this one: Simple Parabolic SAR (SimpleParabolicSAR). Continue and finish. Now you can delete everything above the “OnTick” function and the two comment lines here. The first step is to create a string variable, we need it for the signal, so it’s also called: “signal” and we do not assign any value here because we are going to calculate the value later on. Now let’s actually calculate the SAR indicator, that is done by using the built in iSAR function. The first parameter will be the current symbol on the chart, the second parameter is the period, and you might ask yourself what these two values here mean? Well if you click on to: “Insert /Indicators /Trend /Parabolic SAR” you will see that the parabolic SAR indicator has a stat value of 0.02 and a max value of 0.2. This is actually what we use here 0.02 equals the step value and 0.2 equals the max value. The last parameter here is for a shift, but we don’t want to shift the indicator value to the right or to the left so we use zero. Now let’s find out if the SAR indicator is below the bid price because we know when it’s below, that’s an indicator for an uptrend and in MQL4 we simply use an “if” statement to find out if the SAR value we have calculated here is below the bid price. If that is the case that would be a buy signal, so let’s assign the word “buy” to the variable signal we have created here. In the other case if the SAR indicator is above the ask price – that would be the case here – and it would be a little sell trend and to find out if that is the case we would use the “if” statement and find out if “MySARValue” is above the current ask price. In that case we would have a sell signal, so let’s assign the word sell to the signal variable we have created. And last but not least we want to create a chart output, so we use the built-in command function to output the text: “MySARValue”, followed by the calculated value. This backslash “n” (“/n”) statement creates a new line for the output, and in the second line we want to output the word: “signal” followed by the calculated signal. Okay that’s it! Don’t forget the closing bracket here and when you are finished you can click on the compile button here or press F7 on your keyboard – Oh! I’ve accidentally out commented the “OnTick” function so let’s recompile the code here, and now it says we don’t have any errors and we have no warnings, and if that is the case for you, you can click on a little button here to go back to Metatrader. In Metatrader we use a little trick please click on “Insert /Indicators /Trend /Parabolic SAR”. Okay. Now right click into the template, select template, and save the template as: “tester.tpl” because the tester template is what Metatrader 4 is going to use for your back test. Let’s click on save and select “View/ Strategy Tester” or press CTRL and R and in the Strategy Tester you want to select the “SimpleParabolicSAR.ex4” file. Don’t forget to enable the visual mode here and now click on start. And this is our little Expert Advisor at work, right now the dots are below the candles and it says we have a buy signal, and when it’s going down the dots are above the candles, we will create a sell signal on the chart. Okay. Now you know how to create an Expert Advisor that is able to create buy or sell signals base...
    7 min

About MQL4TUTORIAL.COM

From the publisher's feed

MQL4 Tutorial for Metatrader 4 or MT4 about automated trading, trading robots, MQL 4 and MQL programming