MQL4TUTORIAL.COM

MQL4TUTORIAL.COM

By MQL4TUTORIAL.COMBusinessInvesting
Download on the App Store

MQL4TUTORIAL.COM episodes

  • MQL4 TUTORIAL BASICS – 109 SIMPLE FRACTALS EXPERT ADVISOR
    In this video, we are going to create an expert advisor for this indicator here.    It’s the fractals indicator and the expert advisor is going to open, buy and sell trades based on this value.    So let’s find out how to calculate that with MQL4.   To do that, please click on a 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 file, expert advisor from template. Continue.    I will call this file Simple fractals EA click on, continue, continue, and finish.    Now you can remove everything above the on tick function and the two comment lines here, we start by creating a string variable for the signal, but we don’t assign any values here.    Now let’s actually calculate the values for the fractal indicator, and that is done by using I fractals.      We need to pass a few parameters. The first one is for the current symbol on the chart.    The second one is for the currently selected period on that chart.    The third one is MODE_UPPER. If you mark that and press F1, you will see that MODE_UPPER represents a value of one.    It is used for the upper line of some indicators, and one of them is ifractals.    And we are going to calculate the value for candle two, because Ifractals is not creating the arrows for the current candle.    It creates them for candles in the past.    So if you would use candle zero here, you would get no values.    Let’s repeat that, this time we are going to calculate the lower fractals value.    This is pretty much similar, but this time we are using MODE_LOWER. And this also is the value for candle two.     That’s the third candle because the current candle is candle zero. Now we can check the signal conditions.    And if the lower fractals value is not zero, we want to check if the lower fractals value is below the lower price of candle one.    And if that is the case, we consider that to be a buy signal.    And now we assign the word buy to our signal.    In the other case, when it is going down, we want to check if the upper fractals value is not zero.    And the second condition is that we want to know if the upper fractals value is greater than the high price for candle one, that would be a sell signal.    And that’s when we assign the word sell to our signal.    Now we can check if our signal equals buy. And we also want to know if the return value for orders total equals zero.     That would mean we have a buy signal and no open positions.    And that’s when we use order send to open a buy position for 10 micro lot.    In the other case, if our signal equals sell and we also have no open positions, we use order send to sell 10 micro lot and to see what’s going on, we add a comment statement that will  show us the upper value, the lower value and the current signal on our chart.    And that’s about it.    Well, if this was too fast for you, or if you have no idea what all the code here does, maybe you want to watch one of the other videos of the basic video series, or maybe even the premium course on our website might be interesting for you. That’s actually where you also can find a link for courses that contain all the source codes here.    For now, please click on the compile button or press F7 on your keyboard.     You shouldn’t get any errors. And if that is the case, you can click on a little button here or press F4 to go back to meta trader.   And in meta trader, please pick an empty chart, click on insert indicators, Bill Williams, fractals, click on okay, here is the indicator.    And now we can right click into the chart, select template, save template, and we save it as Tester.tpl, because this is the template that we are going to see in the strategy tester.    You can override the current one, and now you can click on view, strategy tester or press control and R, please pick the new file Simple fractals EA.ex4, mark the option for the visual mode here and start your test.   Here we are,
    7 min
  • MQL4 TUTORIAL BASICS – 108 SIMPLE IOBVEA OSCILLATOR
    In this video, we are going to create an Expert Advisor that is able to create buy or sell position based on oscillator values. So let’s find out how to do that with MQL4. To get started please click on a 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 file, Expert Advisor from template, continue. I will call this file simple. IOBVA. 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.   We start by creating a string variable for the signal, but we are not going to assign a value now. Afterwards, we want to create an array for 100 items. This is a double array. Now let’s use a For loop to go through all the array items and we calculate the value for the array items by using the iOBV function. This will calculate the on balance volume indicator for the current symbol on the chart and the currently selected period on that chart. We use price underscore close for the current counter value and afterwards we are going to add the calculated value to our array.   That’s it for the For loop. Now we need to calculate some values. The first one is the current value for Candle zero. That is calculated by using iOBV for the current symbol on the chart and the currently selected period on that chart. We are using price underscore close.   And we want to calculate the value for Candle zero, that’s the current candle, afterwards, we need to calculate the candle number for the highest candle in our array. And we can do that by using array maximum for the array that we have created. We want to search the whole array starting from item number zero. That’s the first item in our array. And this function will get the number for the highest candle. Therefore, we repeat the whole thing and this time we use array minimum to get the number of the lowest candle, because once we know the number of the candle, we can calculate the value by simply looking into the number of the highest candle, we will get the maximum value.   And it is very similar to get the minimum value by looking into our array for the candle number that we have calculated here. So let’s check for the signal because of the current value for Candle zero is bigger or equal, the max value that we have calculated, we would consider that to be a buy signal and that’s when we assign the word buy to our signal. Otherwise, if the current value is below or equal, the minimum value that we have calculated, that would be a sell signal.   And that’s when we assign the word sell to our signal. And when our signal equals buy and OrdersTotal is zero, that would mean we have no open positions and a buy signal and that’s when we use Ordersend to buy 10 Microlot. In the other case when the signal equals sell and we also have no open orders, we use Ordersend and OP_SELL to sell 10 Microlot. Finally, we use the comment statement. This will create a chart output and it will output the current, the max, the min and the signal value.   And that’s about it. Well, if this was too fast for you or if you have no idea what all the code here does, you maybe want to watch one of the other videos in the basic video series first or maybe even the Premium Course on our website might be interesting for you. That’s also where you can find links to source codes in case you don’t want to type everything. But for now, please click on the Compile button or F7 on your keyboard.   You shouldn’t get any errors here. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader we use an empty chart and click on insert indicators, volumes, on balance volume. You can go with the default values here and click on OK, here is the oscillator. Now lets rightlick into the chart, select template, save template and we want to save it as tester.tpl.   You can override the current value because this is wh...
    7 min
  • MQL4 TUTORIAL BASICS – 107 SIMPLE ARRAY REFERENCE
    In this video, we are going to create an Expert Advisor that is able to pass a complete array as a parameter to different function. So let’s find out how to do that with MQL4. To get started, please click on a 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 file, Expert Advisor from template, continue. I will call this file simple array reference. Click on continue, continue and finish.   Now you can delete everything above the ontick function and the two comment lines here. We start by creating a small array. This is an integer array and we want to fill our array with a few numbers. Please keep in mind that the first array item is always index zero. These array items are like boxes and we assign values to these boxes. This is just for a simple example and it’s a good idea to create small little programs like this one to find out how things work, because now we want to find out if we are able to pass our array as a parameter to a user defined function that is called add values.   This function doesn’t exist so far, so we need to create it in a few seconds and we will get a returned result. So let’s create a chart output here. By using the comment statement. It will output the text the returned result is followed by the result that we have created, but this function doesn’t exist so far. So we need to create it now and our function will be called add values and it will get to the array as a single parameter.   And we are using this little trick here. This is for INT Integer and this little ampersands symbol is used for references, so now we can try to add a few values by adding the array indexes zero, one and two, and finally we use the return statement to return the result to the main function, and that’s about it. Well, if you have no idea what all the code here does or if this was too fast for you, maybe you want to watch one of the other videos in this basic video series.   And on our website, you can now find a link for basic courses that also contain the source codes for this basic video stuff. There is also the link for the Premium Course. This was another idea of a Premium Course member. And if you are already a Premium Course member and have an idea for a video like this one, please let me know. For now, please click on the Compile button or press F7 on your keyboard, that should work without any errors.   And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader we click on View, Strategy tester or press Control and R.   Please pick the new file simple array reference dot EX4.   Enable the visual mode here and start your test. Here is the Expert Advisor, and it says the returned result is fifty six. So now let’s go and check the source code. We have added up eight and 16. So this would be 24. The third item here is thirty two. And if we add all three items, the result is fifty six. So let’s actually add another value here for index three. Now recompile the code, stop the current test and restart it.   And this time it says that the returned result is one hundred and twenty. And in this little video, you have learned how to add up all the elements of an array that we have passed by a reference, and you have coded it yourself with a few lines of MQL4 code.
    6 min
  • MQL4 TUTORIAL BASICS – 106 SIMPLE ICHIMOKU KINKO HYO
    In this video, we are going to create an Expert Advisor that is able to calculate the values for this indicator here. This one is called Ichimoku Kinko Hyo. So let’s find out how to do that with MQL4. To get started, 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 file, Expert Advisor from template, continue. I will call this file SimpleIchimokuKinkoHyo, now click on continue, continue and finish.   Now you can delete everything above the Ontick function and the two comment lines here. We start by calculating the Tenkansen value. To do that, we use Iichi Moku. If you mark that on press F1, you will see that it takes a few parameters that we need to pass.   The first one is for the current chart. That’s the symbol, the second parameter is for the time frame. So we also can use underscore, symbol and underscore period. Here we have three values and when you click on insert, indicators, custom, Ichimoku, you will see that the Tenkansen value is nine, the Kijunsen value is twenty six and the Senkuspan B value is fifty two. And that’s exactly what we are using here. The next parameter is for the value you want to calculate.   If you mark that and press F1 you will see that we need to do that for five values.   And the first one is Mode_Tenkansen. The last parameter here is for the number of the candle. So let’s do that for the current candle that is Candle zero. Now let’s continue with the Kijunsen value that is very similar. But this time we are going to use Mode_Kijunsen. But now comes the tricky part. Because to calculate the right value for the Senkuspan A you need to pass Mode_SenkouspanA followed by a value of minus twenty six candles.   Why is that? Well, if you take a closer look, you will see that this is the current candle and this cloud here is calculated in front of the current candle. Therefore, we need to use a negative value here. And that is also true if we want to calculate the Senkouspan B value. Now, we use Mode_SenkouspanB.   Again, followed by a value of minus 26 candles, and the next thing is this green line here, this is not calculated into the future, but into the past. So to calculate the Chinkouspan value, we need to use Mode_Chinkospan. And this time we are going to use a value of twenty six candles. But this is a positive value, not a negative one. If you don’t know those values, you would probably get wrong values, because you would try to calculate the values for the current candle, and that can be very confusing, especially in the beginning.   Now let’s add a comment statement for the chart output that will show us the description and the values on the chart, and that’s about it. Well, if you have no idea what all the code here means or if you think that this was too fast for you, you maybe want to watch one of the other videos in the basic video series or maybe even the Premium Course on our website might be interesting for you. There we also have a link for basic video courses that contain the source codes.   And this video actually was suggested by a Premium Course member. And if you are a Premium Course member and have an idea for a video like this one, please let me know. For now please  click on the Compile button or F7 on your keyboard. You shouldn’t get any errors. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader you want to click on insert, indicators, custom, Ichimoku, please go with the default values and click on ok.   Now the indicator should appear on your chart and now you want to right click select template, save template and save it as tester.tpl. You can override the current value because tester.tpl is the template that we will see when we start the next strategy test. So now please click on View, strategy tester or press Control and R. Please pick the new file SimpleIchimokuKinkoHyo.EX4,
    8 min
  • MQL4 TUTORIAL BASICS – 105 SIMPLE SELL GRID SYSTEM
    In this video, we are going to create a sell grid system that will open sell trades when we have a falling trend. So let’s find out how to do that with MQL4. To get started, please click on a 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 file, Expert Advisor from template, continue. I will call this file Simple Sell Grid System. Click on continue, continue and finish.   Now you can delete everything above the Ontick function and the two comment lines here. First, we need a string variable for the signal, that will also be called signal and we do not assign a value here because we are going to calculate that later. Inside of the ontick function we create a static double variable called Next sell price. We are going to use that for the next price level and if we have no open positions, that would be the case when OrdersTotal returns the value of zero, we want to set the next sell price level to zero. To find out if we have a sell signal we are going to use a function that is called check entry signal. This function does not exist so far, so we need to code it in a few minutes. For our sell position we want to check a few conditions. First, we want to check if the Bid price is below the next sell price level that we have defined or if the next sell price is zero, the next condition we want to check is if the signal has been a sell signal.   If both conditions are true, we are going to use ordersend for the current symbol on the chart to open a sell trade for 10 Microlot. And right afterwards we are going to set the next sell price level to a value 30 points below the Bid price. Let’s add a comment statement to output the Bid price and the next sell price on our chart so we see what’s going on. So far this is it with the Ontick function. But remember, the function for the entry signal still needs to be created.   Our function will have the name check entry signal and it will return a string value to calculate the current signal. We are going to use something very easy. We want to check if the close price for candle one is bigger than the open price for candle one. If that is the case, we consider that to be a buy signal. So now we assign the work buy to our signal. In the other case, if the close price for candle one is below the open price for candle one that would be a sell signal. And in that case we would assign the word sell to our signal.   Finally, we use the return statement to return the signal to our main module, and that’s about it. Well, if this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos or maybe even the Premium Course on our website might be interesting for you. That’s where you actually can also find a link for source codes like in this video. But for now, please click on the Compile button or press F7 on your keyboard.   I don’t have any errors here. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader you want to click on View, Strategy tester or press Control and R, please pick the new file simple sell grid system, dot EX4 and the Visual mode here and start your test. Here we are. This is our first position. I will increase the speed a little bit and now you’ll see that we have a second position and a third one.   So our little Expert Advisor works as expected. And in this little video you have learned how to create a sell grid system for Metatrader4 and you have coded it yourself with a few lines of MQL4 code.
    5 min
  • MQL4 TUTORIAL BASICS – 104 SIMPLE SELL CROSSOVER STOP LOSS
    In this video, we are going to create an Expert Advisor that is able to close open sell positions when the trend changes and we see a crossover. So let’s find out how to do that with MQL4. To get started, please click on a 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 file, Expert Advisor from template continue. I will call this file simple sell cross over, stop, click on continue, continue and finish. Now you can delete everything above the Ontick function and the two comment lines here. We start by creating a string variable for the signal. This variable is also called signal and we don’t assign a value here because we are going to calculate it later.   The next step is to calculate the small moving average for candle one. That is done by using the IMA function. For the current symbol on the chart and for the currently selected period on that chart. We want to calculate the IMA for 20 candles, we don’t use a shift value here. And because we want to calculate a simple moving average, we are going to use Mode underscore SMA for an exponential moving average you could use Mode underscore EMA.   The result should be calculated based on the close price for candle one. The calculation for the big moving average for candle one is pretty similar. The only difference is the name for the variable and we are going to calculate it for 50 candles in this case. Now that we know those values, we can find out if the big moving average one for candle one is bigger than the small moving average for candle one. And if that is the case, that would be a Sell signal.   So we assign the word sell to our signal. In the other case, if the value for big moving average one is below the value for small moving average one, we would consider that to be a buy signal and then we would assign the word buy to our signal. And when our signal equals sell and the return value for OrdersTotal equals zero, that would mean we have a sell signal and no open orders. And now we use Ordersend to open a test position for 10 Microlot.   Please keep in mind this is only a test position, we need to open a position so we can check if the moving average sell cross over Stop Loss is working. But you wouldn’t do that on a real account. In the other case, when we have a buy signal and we have open orders, that would mean that OrdersTotal is bigger than zero. We want to call a function that is called close sell position this pair and close all the open sell position.   Let’s add a comment statement here that will output the text the current signal is followed by the calculated signal. And that’s it for the Ontick function, but to use this function, we need to create it now because it doesn’t exist. Our function uses void because we don’t need a return value. The name is close sell positions this pair and we are going to use For loop to go through all the open positions. We use orderselect to select the position for the current counter value.   Now we want to find out the current currency pair that is done by using order symbol and that makes it possible to check if the current symbol on the chart matches the currency symbol. We also want to find out if the order type equals OP_SELL and if those conditions are true, we use orderclose for the current order ticket and the current order lot size to close the current position. Finally, we need to close the For loop and the function, and that’s about it.   If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in the basic video series or maybe even the Premium Course on our website might be interesting for you. Now we have a link on that website where you can find the source codes for these basic videos. But for now, please click on the Compile button or press F7 on your keyboard. You shouldn’t get any errors.   And if that is the case,
    8 min
  • MQL4 TUTORIAL BASICS – 103 SIMPLE BUY GRID SYSTEM
    In this video, we are going to create an Expert Advisor that is able to set buy prices as a grid system when we have an uprising trend. So let’s find out how to do that with MQL4. To get started. Please click on a 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 file, Expert Advisor from Template, continue. I will call this file simple buy grid system.   Click on Continue, continue and finish.   Now you can delete everything above the ontick function. And let’s also delete the two comment lines here, we start by creating a global variable called signal. This is a string variable so it can hold text values, but we don’t assign any values here because we are going to calculate that later. Inside of the ontick function we want to create a static variable. Static is a modifier that will exist during the whole lifetime of the MQL4 program. We use double because we need floating types.   And the name of the variable is next buy price, we are going to use it to set the next buy price level for the grid system and we want to check if OrdersTotal equals zero. That would be the case when we have no open positions. In that case, we set the buy price to zero. Afterwards we want to call a function that is called check entry signal. This function doesn’t exist so far. We need to create it later. And that will check if we have a buy or a sell signal, one of the conditions to open a buy trade would be if the Ask price is above or equal to the next buy price.   The second condition is that we want to check if the signal equals buy and if both conditions are true, we are using Ordersend to open a buy trade for 10 Microlot and we also want to set the next buy price level. So now we are going to calculate the next buy price buy using the current Ask price and adding 30 points. Let’s add a comment statement. That will output the current Ask price and the next buy price directly on our chart. This function doesn’t exist so far, so we need to create it now. The name of the function will be check entry signal. It’s a string function. That means it will return a string value. We use a very simple way to find out if we want to buy or sell. In our case, we want to check if the last candle is bullish. That would be the case when the close price for candle one is bigger than the open price for candle one. If that is true, we assign the word buy to our signal.   In the other case, when the close price for candle one is below the open price for candle one, that would be a sell signal. And now we assign the word sell to our signal. Finally, we want to return the signal to the main module and that’s about it. If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in the basic video series.   Or maybe you want to buy the Premium Course, you can find that one on our website. This was actually suggested buy a Premium Course member. And if you are already a premium member and have an idea for such a video, please let me know. For now, we want to click on the Compile button or press F7. I don’t have any errors here. And if that is the case, we can click on a little button here or press F4 to go back to Metatrader.   And in Metatrader we want to click on View, Strategy tester or press Control and R. Please pick the new file simple buy grid system dot EX4, mark the option for the visual mode here. And start your test. Here we are. The Expert Advisor is running and once we see a rising trend, we should see additional positions. That happened right now, so our little Expert Advisor works as expected, and in this little video, you have learned how to create a simple buy grid system and you have coded it yourself with a few lines of MQL4 code.
    6 min
  • MQL4 TUTORIAL BASICS – 102 SIMPLE BUY CROSSOVER STOP
    This video, we are going to create an Expert Advisor that is able to open buy trades or close them when two moving averages are crossing. So let’s find out how to do that with MQL4. To get started please click on a little icon here or press F4 on your keyboard.    Now, you should see the Metaeditor window and you want to click on file, new file, Expert Advisor from Template, continue. I will call this file simple Buy Cross Over Stop. Click on Continue, continue and finish. Now you can delete everything above the Ontick function and the two comment lines here. We start by creating a string variable for the signal. That is called signal and we don’t assign a value here. Afterwards, we want to calculate the small moving average. That is done by using the IMA function for the current symbol on the chart and the currently selected period on that chart.   The small moving average should be calculated for twenty candles. We don’t use a shift value here. We use Mode_SMA, that stands for simple moving average. Of course, you could also use something like EMA for exponential moving average.   The results should be calculated based on the close price and we want to calculate the result for candle one. Now we want to repeat that for the big moving average. The big moving average in our case will be calculated for fifty candles. Everything else is the same, except for the variable name here and now we can calculate the signal, because when the big moving average is bigger than the small moving average for candle one, that would be a sell signal for us.   So we assign the words sell to our signal. In the other case, if the big moving average is below the small moving average for candle one, that would be a buy signal. So now we assign the word buy to our signal. This is about closing positions and to close something we need to open buy positions by using ordersend. We want to do that when the signal equals buy and when the return value for OrdersTotal is zero. That would mean we have no open orders and now we want to open a test position by using Ordersend for the current symbol on the chart, we are going to open a position for ten Microlot. We have Take Profit value of one hundred and fifty points.   Of course you only would do this on a demo account, not on a real account. And we do it to close positions when we have a cross over. So when the signal equals sell and we have open orders, that would be true when OrdersTotal returns a value that is above zero, then we want to call a function called close-buy positions this pair. And to see what’s going on, we want to use a comment statement to output the text.   The current signal is followed by the calculated signal directly on our chart. So far so good. But this function doesn’t exist so far, so we need to create it now. The name of the function is close buy positions this pair.   We use void because we don’t require a return type and now we use a for loop to go through all the open orders. Afterwards, we use order select to select a position for the current counter value of the for loop. We need to get the current currency pair. That can be done by using Order symbol. And now we want to check if the symbol on the chart and the currency pair are equal. And as we only want to close buy positions, we also check if the order type equals OP_BUY.   And if those conditions are true, we want to close the order. That is done by using order close for the current order ticket and the current order lots, we are going to close the order for the Bit price. The slippage is three and the last parameter here would be the color. I haven’t assigned a particular color here, but usually it’s red. Now let’s close the for loop and close the function and that’s about it. If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in the basic video series first, or maybe even the Premium Course on our website might be interesting for you.
    8 min
  • MQL4 TUTORIAL – 101 WHAT HARDWARE FOR ALGORITHMIC TRADING
    In this video, I would like to talk about one of the questions that I get from time to time. Actually, I am dealing with the whole topic right now, because I’m going to do another experiment in February and therefore I needed to buy a new device. This is the crowd algo trading system. I did a daily video about this new system each day in January. And in February I’m going to do the same live experiment for MQL5. Therefore, I needed to have new hardware.   So let’s go through all the options that I’m using right now. This Metatrader installation is running on a so-called virtual machine. I’m using a software that is called Virtual Box. You can download it from the Internet for free. And basically, it will help you to run one operating system in a window inside of a host operating system. You now should see the Windows operating system. This is the virtual device, Windows 10. You can use virtual machines for a lot of things.   In my case, I have been coding on the Windows machine and I’m using this virtual machine right now to record this video. But my daily work is done on a Linux machine. I’m using MX Linux, and I think that virtual machines are a very good solution. But if you don’t want to use virtual machines, you can use a software like this, VNC viewer to connect to real machines. I have a lot of them. So let’s connect to this one.   And you will see this is running the Metatrader. I can move the whole application around. And this is a Windows eight machine with two gigabytes of RAM. This is enough to run Metatrader. Now let’s disconnect and open another one. This one is a Windows 10 machine and it’s also running with two gigabytes of RAM on a 32 bit system. By the way, these are both so called compute stick’s. A compute stick is a little device that is a little bit bigger than a usual USB stick might be. It comes with an HDMI output so you can use it on any screen or any TV. And it doesn’t need much space.   I have several of those. They all have two gigabytes of RAM. But for the new system, I decided to use a different solution. This is also a very small PC. It’s a little bit bigger than a cigarette box. You see the pen here. This is also a micro keyboard. So the whole thing would fit in your pocket. And this little device comes with four gigabytes of RAM and windows 10 is already preinstalled. You can get this device for a little over 100 dollars online.   It has several USB ports and an HDMI output. So this is very affordable and this is what I consider to be the coolest version. These are two super small notebooks. You might know that we had this kind of hardware about 20 years ago, but at this time, those little devices came with Windows Mobile or Symbian OS, and you couldn’t do very much because the performance was really bad.   But these two little things here come with a full blown Windows 10 system and eight gigabytes of RAM. That is more than enough to use it for Metatrader. And you also can use them for other cool things, for example, for mobile programming. But they are costly. If you don’t want to spend that kind of money, you could go and buy a used netbook. This device is about 10 years old. It has two gigabytes of RAM. It’s running MX Linux right now.   And with play on Linux and wine, you can emulate Windows programs. So it is possible to run Metatrader on this device. It’s not the fastest solution, but it doesn’t cost very much. You can get devices like this one for 50 to 100 dollars and the keyboard is very usable, but they are a little bit bigger than the last one. When I started out, I had about six of those netbooks on my desk and they did the job very well.   So this is my setup that I prefer. Today I’m running Linux on my desktop PC and this is Windows 10 in the background, running on a virtual machine.   You could run this configuration on your desktop PC or of course, on a notebook.   And when I’m not at home, I also can watch my accounts on this mobile device here.
    7 min
  • MQL4 TUTORIAL BASICS – 100 SIMPLE TRIANGLE OBJECT
    In this video, we are going to create a dynamic object, it’s a triangle object, and it will change the shape whenever the prices change. So let’s find out how to do that with MQL4. To get started, please click on a 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 file, Expert Advisor from Template continue. I will call this file Simple Triangle Object.   Click on continue, continue and finish. Now we can delete everything that is above the ontick function and let’s also delete the two comment lines here. First, we want to calculate the highest of the last thirty candles. That can be calculated by using the function ihighest because ihighest is a function that will return the maximum value over a specific number of bars. In our case, for the current symbol on the chart and the currently selected period on that chart, we use ModeHigh because ModeHigh will give us the highest prices of the candles.   We want to do that for 30 candles and the starting point is candle zero. If we cut that out, we will see that this is the starting index. Now, let’s repeat the whole process. This time we want to calculate the lowest of the last 30 candles. And this can be done by using Ilowest. For the current symbol on the chart and the currently selected period on that chart. This time, we are going to use ModeUnderscoreLow. Also for 30 candles, starting with Candle zero, and before we start to draw our object, we want to use object_delete, and that will remove any former objects with the same name from our chart.   We will use the name Triangle for our object. And the very first time we start the code, we will not have anything to delete. But afterwards we want to make sure that former objects are removed before we draw the new one. Now we can actually create the object by using object_create. This function takes a lot of different parameters and depending on the object type you use, you might need to use different parameters. We are going to create an object that is called triangle.   This is the object type, it’s OBJ triangle, and if you mark that and press F1, you will see that there are also lots of different other object types. We are going to use this one. This will draw a shape like this on our chart. We want to draw the object on our main chart. That’s the chart with the candles. And the triangle needs three reference points. The first one is the point in time where we have candle 30.   The anchor point for our triangle will be the close price for candle thirty.   It will be drawn until the time where we have the lowest candle and therefore the lowest price of the lowest candle. And the other side should be drawn to the point in time where we have the highest of the last 30 candles and the reference point will be the highest price of the highest candle. It’s actually possible to reformat the whole statement. So now it is not so hard to read anymore, and that’s about it. If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos and the basic video series or maybe even the Premium Course on our website might be interesting for you.   For now, please click on the Compile button here or F7 on your keyboard. You shouldn’t get any errors.   And if that is the case, you can click on a little button here or press F4 to go back to Metatrader.   And in Metatrader you want to click on View Strategy tester. Or press Control and R. Please pick the new file. Simple triangle object dot EX4 mark the option for the visual mode and start your test. And here we are. We have a triangle object on the chart. We can also speed up the whole thing, and whenever the prices change, we see that the object is readjusted or in our case, it’s deleted and we draw a new object. So in this little video, you have learned how to create a dynamic triangle object and you have coded it yourself with a few lines of MQL4 code.
    6 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