MQL5 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. It is called the Ichi Moku Kinko Hyo. So let’s find out how to do that with MQL5. 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 Ichi Moku Kinko Hyo. He or click on Continue, continue and finish.

 

Now you can delete everything above the Ontick function and the two Comment lines here, we start with an import statement that will import the file Trend.mqh.

 

This one comes with MQL5 and it provides a few additional trend help classes.

 

One of those classes is this one. It is called C I Ichi Moku.

 

Here is the declaration and some additional information.

 

We have methods that have been inherited from other classes. Here is the class hierarchy. Basically, it’s an object and we want to create an instance that is called I ichi Moku. This is actually not a mistake. Please don’t forget to use this asterisk. Now, we are going to continue with the on init function.

 

We want to create the I ichi Moku only once that is done by using new C I ichi Moku. Here comes the actual creation. We create an instance for the current symbol on the chart and the currently selected period on that chart, followed by three values: nine, twenty six and fifty two. And you will see the same values when you click on insert indicators, trend, Ichimoku Kinko Hyo. The Tenkasen value is nine. The Kijunsen value is twenty six and the value for Sekuspan B is fifty two.

 

And that’s exactly what we are going to use here. So now we have created our indicator object. We want to use Ichimoku.Refresh. That is one of the inherited methods from C Indicator and they say it updates the indicator data and it is recommended to call this method before we get the data. Now let’s calculate the values. The Tenkansen value is calculated by using Ichimoku.Tenkansen  for candle zero. The Kijunsen value is calculated by using Ichimoku.Kijunsen for the current candle. The Senkouspan A value is calculated by using Ichimoku.Senkouspan A four minus twenty six candles. And that might look a little bit confusing. But if you take a closer look, you will see that this cloud here is calculated ahead of the current candle.

 

Therefore we need to use this negative value here. Otherwise, it would be calculated for the current candle and that would be wrong. That can be really confusing, especially in the beginning, because you would get wrong values. Let’s continue with the Sekuspan B value. That’s basically the same. This one is also calculated for minus twenty six candles, and the last one is the Chinkospan value. To calculate this, you use Ichimoku.Chinkospan and this time we are going to use twenty six candles because this Chinkospan value is calculated for twenty six candles in the past.