MQL5 Tutorial

MQL5 TUTORIAL – ADVANCED WPR EXPERT ADVISOR


Listen Later

In this video, we are going to talk about the Williams’ Percent Range indicator. It is traded automatically right now. We use the Golden Goose Framework in the English version… Right now, it’s equity positive and the balance is also positive. We started with 100.000 US Dollar so if I would close this account right away we would have made a profit of 277 Dollars but I am not going to do that. This very fast running oscillator down here has been invented by a guy named: Larry Williams. Now we are going to find out how we can create an expert advisor that is able to trade this oscillator automatically. To do that please click on the little button here or press F4 in your Metatrader. Now you should see the Metaeditor and here you want to create a file called: CheckEntry_WPR.mq5. It will use a function called CheckEntry that will deliver a string value for the calculated buy or sell signal. We need to create an empty string that will be called signal, but we won’t assign a value right now because we going to calculate that later. We also need to create an array for several prices, that one will be called: WPR-Array[] for Williams’ Percent Range and it’s a double array because it needs to hold floating point values for the prices. In the next step, we are going to create WPRDefinition by using the mql5 built-in function: iWPR. This one takes only three parameters. The first one will be the currency pair in your chart, the second one will be the selected period on your chart and the last parameter has a value of 14 because if you click on Insert/Indicators/Oscillators/Williams’ Percent Range you will see that is calculated for 14 candles. Now we need to sort our array from the current candle downwards. This is done by using ArraySeAsSeries for the WPRArray we have created here and with CopyBuffer we will fill the WPRArray according the WPRDefinition we have created here and we will do that for the first line that’s buffer 0 from the current candle 0 for 3 candles. Now let’s get the value for current the candle! To do that we will get the variable called WPRValue that will look into the WPRArray and it will get the values for candle[0], and with NormalizedDouble and the 2 here we make sure that we calculate only two digits behind the dot. By the way; this expert advisor made 12 hundred dollars so far. And of course, we need to calculate the buy signal now that will always be the case when the value of the line here is between -80 and -100. So if WPRValue is below -80 and above -100 we want to assign the text “buy” to our signal. In the other case, to create a sell signal, we will check if the WPRValue is above -20 and below 0, that would be a sell signal because that is the area above the dotted line here. That’s the -20 mark and this would be the 0 mark. Right now, we made 13 hundred and 70 dollars, but now let’s continue. The final step for our module here is to return the calculated signal to the main module. That will be done by using the return command and now we close the whole module and the function CheckEntry with the final bracket. If you are ready, please click on save because you don’t compile the entry module. In my case I need to compile the main module. This is the Golden Goose Framework. This framework basically is a collection of functions that can be imported. They all have been pre-coded in the so called library. This is the file where we have defined the complete behavior for the trading framework. If you don’t know what a framework is you can basically imagine a trade management system that you can use again and again. It will enable you to trade up to 22 currency pairs and several positions at the same time. Obviously, I can’t explain the whole framework in a 5 to 10 minutes video. If you are interested in getting the framework or coding your own framework just visit my website, you will see the URL at the end of this video.   But back to topic. We are going to import our entry module here and call the CheckEn...
...more
View all episodesView all episodes
Download on the App Store

MQL5 TutorialBy Raimund Bauer