MQL4 TUTORIAL BASICS – 106 SIMPLE ICHIMOKU KINKO HYO

video
play-sharp-fill

 

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, mark the option for the visual mode and start your test. Here we are. Our Expert Advisor is running , I will fastforward. Now, I will pause it and let’s check if we have calculated the right values, the first one is for the Tenkansen. It says we have one point one four eight nine Now let’s put the mouse onto the red line. It says Tenkansen one point one four eight nine.

 

That’s what we have calculated here. The Kijunsen is one point one four eight two. That is exactly what we get when we look at the current value for the blue line.

 

The Senkouspan A value is one point one four eight five eight. Eight five eight is rounded to eight six here. The Senkouspan B value is one point one four seven four four.

 

That is rounded to one point one four seven four.

 

And the Chikouspan value is one point one four nine three nine.

 

That is rounded to one point one four nine four here, so all the values have been calculated correctly. And in this little video, you have learned how to create an Expert Advisor that is able to calculate all the values for the IchimokuKinkoHyo indicator. And you have coded it yourself with a few lines of MQL4 code.