The CIchimokuOnArray class is intended for calculation of Ichimoku (Ichimoku Kinko Hyo) values on indicator buffers.
Usage:
The Init() method with the following parameters is called in the OnInit() function of the indicator:
- int aPeriodTenkan is the Tenkan period;
- int aPeriodKijun is the Kijun period;
- int aPeriodSenkou is the Senkou period;
- bool aABShift determines whether to calculate the SpanA and SpanB lines with shift or not. If the value is True, the SpanA and SpanB lines are shifted during calculation; in this case, there will be no future data for these lines. If the value if False, shift the SpanA and SpanB lines using the PlotIndexSetInteger() function with the PLOT_SHIFT identifier.
The Solve() method with the following parameters is called in the OnCalculate() function:
- const int aRatesTotal is the rates_total variable from the OnCalculate() function parameters;
- const int aPrevCalc is the prev_calculated variable from the OnCalculate() function parameters;
- double aDataHigh[] is the buffer with the High data for the indicator calculation;
- double aDataLow[] is the buffer with the Low data for the indicator calculation;
- double & aTenkan[] is the buffer with calculated values of the Tenkan line;
- double & aKijun[] is the buffer with calculated values of the Kijun line;
- double & aSpanA[] is the buffer with calculated values of the SpanA line;
- double & aSpanB[] is the buffer with calculated values of the SpanB line.
Additional methods:
- int SpanABShift() returns the shift of the SpanA and SpanB lines;
- int BarsRequiredTK() returns the number of bars required for calculation of the Tenkan and Kijun lines;
- int BarsRequiredAB() returns the number of bars required for calculation of the SpanA and SpanB lines;
- string Name() returns a string with the indicator name;
- string NameT() returns a string with the Tenkan line name;
- string NameK() returns a string with the Kijun line name;
- string NameSA() returns a string with the SpanA line name;
- string NameSB() returns a string with the SpanB name.
The Test_IchimokuOnArray.mq5 file is an indicator demonstrating how to use of CIchimokuOnArray class. The IncIchimokuOnArray must be located in the MQL5\Include\IncOnArray directory of the terminal data folder (the IncOnArray folder must be created).
Ichimoku Kinko Hyo Technical Indicator is predefined to characterize the market Trend, Support and Resistance Levels, and to generate signals of buying and selling. This indicator works best at weekly and daily charts.