5 épisodes

MQL4 Tutorial for Metatrader 4 or MT4 about automated trading, trading robots, MQL 4 and MQL programming. Improve your trading results within 5 minutes a day!

MQL4 TUTORIAL MQL4 TUTORIAL

    • Affaires

MQL4 Tutorial for Metatrader 4 or MT4 about automated trading, trading robots, MQL 4 and MQL programming. Improve your trading results within 5 minutes a day!

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

    MQL4 TUTORIAL – PLATIN SYSTEM – WILLAMS PERCENT RANGE ENTRY SIGNAL

      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.Not sure what to do? Click on the automated trading assistant belowMQL4-TUTORIAL-PLATIN-SYSTEM-MACD-OSCILLATOR       In this video, we want to calculate…a href="https://mql4tutorial.

    • 4 min
    • video
    MQL4 TUTORIAL – SIMPLE SMA STANDALONE EXPERT ADVISOR

    MQL4 TUTORIAL – SIMPLE SMA STANDALONE EXPERT ADVISOR

    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 opti

    • 5 min
    • video
    MQL4 TUTORIAL – SIMPLE COMMODITY CHANNEL INDEX

    MQL4 TUTORIAL – SIMPLE COMMODITY CHANNEL INDEX

    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 sel

    • 5 min
    • video
    MQL4 TUTORIAL – FIND REMOVE AND FIX CORRUPTED BACKTESTING DATA

    MQL4 TUTORIAL – FIND REMOVE AND FIX CORRUPTED BACKTESTING DATA

    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”.Not sure what to do? Click on the automated trading assistant belowMQL4 TUTORIAL - 197 DAYS - REAL TRADING RESULTS WITH MQL5   This video shows how 197 days of real trading…a href="https://mql4tutorial.com/mql4-tutorial-english/the-equity-stop-how-to-find-the-best-stop-loss-percentage-sol...

    • 4 min
    • video
    MQL4 TUTORIAL – HOW TO GET THE LAST ERROR

    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 belowa href="https://mql4tutorial.com/mql4-tutorial-english/mql4-tutorial-basics-113-simple-sell-perc...

    • 5 min

Classement des podcasts dans Affaires

Génération Do It Yourself
Matthieu Stefani | Orso Media
Émotions (au travail)
Louie Media
L'Art de la Gestion Patrimoniale
Bonnet Doyen Conseil : Épargner, Investir, Entreprendre, Immobilier, Impôts
Finary Talk
Finary
J'peux Pas J'ai Business par TheBBoost
TheBBoost
Le Podcast de Pauline Laigneau
Pauline Laigneau