Add dot fill in Ichimoku indicator

 
Hello to all
How can I change the style of the cloud in Ichimoku to point fill? As in the Metatrader indicator?
Thank you very much

with respect

Like this:

Like this:

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   4
#property indicator_type1   DRAW_LINE
#property indicator_type2   DRAW_LINE
#property indicator_type3   DRAW_FILLING
#property indicator_style3  STYLE_DOT
#property indicator_type4   DRAW_LINE
#property indicator_width1  2
#property indicator_color1  clrRed
#property indicator_width2  2
#property indicator_color2  clrDeepSkyBlue
#property indicator_color3  C'0,53,0', C'141,27,27'
#property indicator_color4  clrWheat
#property indicator_label1  "Tenkan-sen"
#property indicator_label2  "Kijun-sen"
#property indicator_label3  "Senkou Span A;Senkou Span B"
#property indicator_label4  "Chikou Span"
//--- input parameters
input group "Settings:";
input int InpTenkan = 9;            // Tenkan-Sen
input int InpKijun = 26;            // Kijun-Sen
input int InpSenkou = 52;           // Senkou Span B
input group "Offsets:";
input int InpTenkansenOffset = 0;   // Tenkan-Sen Offset
input int InpKijunsenOffset = 0;    // Kijun-Sen Offset
input int InpCloudOffset = 26;      // Cloud Offset
input int InpChikouOffset = -26;    // Chilou-Span Offset
//--- indicator buffers
double    ExtTenkanBuffer[];
double    ExtKijunBuffer[];
double    ExtSpanABuffer[];
double    ExtSpanBBuffer[];
double    ExtChikouBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
   SetIndexBuffer(0, ExtTenkanBuffer, INDICATOR_DATA);
   SetIndexBuffer(1, ExtKijunBuffer, INDICATOR_DATA);
   SetIndexBuffer(2, ExtSpanABuffer, INDICATOR_DATA);
   SetIndexBuffer(3, ExtSpanBBuffer, INDICATOR_DATA);
   SetIndexBuffer(4, ExtChikouBuffer, INDICATOR_DATA);
//---
   IndicatorSetInteger(INDICATOR_DIGITS, _Digits + 1);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpTenkan);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpKijun);
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, InpSenkou - 1);
//--- lines shifts when drawing
   PlotIndexSetInteger(0, PLOT_SHIFT, InpTenkansenOffset);
   PlotIndexSetInteger(1, PLOT_SHIFT, InpKijunsenOffset);
   PlotIndexSetInteger(2, PLOT_SHIFT, InpCloudOffset);
   PlotIndexSetInteger(3, PLOT_SHIFT, InpChikouOffset);
//   -- change labels for DataWindow
   PlotIndexSetString(0, PLOT_LABEL, "Tenkan-sen(" + string(InpTenkan) + ")");
   PlotIndexSetString(1, PLOT_LABEL, "Kijun-sen(" + string(InpKijun) + ")");
   PlotIndexSetString(2, PLOT_LABEL, "Senkou Span A;Senkou Span B(" + string(InpSenkou) + ")");
//--- initialization done
   return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| get highest value for range                                      |
//+------------------------------------------------------------------+
double Highest(const double&array[], int range, int fromIndex)
{
   double res = 0;
//---
   res = array[fromIndex];
   for(int i = fromIndex; i > fromIndex - range && i >= 0; i--) {
      if(res < array[i]) res = array[i];
   }
//---
   return(res);
}
//+------------------------------------------------------------------+
//| get lowest value for range                                       |
//+------------------------------------------------------------------+
double Lowest(const double&array[], int range, int fromIndex)
{
   double res = 0;
//---
   res = array[fromIndex];
   for(int i = fromIndex; i > fromIndex - range && i >= 0; i--) {
      if(res > array[i]) res = array[i];
   }
//---
   return(res);
}
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo                                               |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   int limit;
//---
   if(prev_calculated == 0)
      limit = 0;
   else
      limit = prev_calculated - 1;
//---
   for(int i = limit; i < rates_total && !IsStopped(); i++) {
      ExtChikouBuffer[i] = close[i];
      //--- tenkan sen
      double _high = Highest(high, InpTenkan, i);
      double _low = Lowest(low, InpTenkan, i);
      ExtTenkanBuffer[i] = (_high + _low) / 2.0;
      //--- kijun sen
      _high = Highest(high, InpKijun, i);
      _low = Lowest(low, InpKijun, i);
      ExtKijunBuffer[i] = (_high + _low) / 2.0;
      //--- senkou span a
      ExtSpanABuffer[i] = (ExtTenkanBuffer[i] + ExtKijunBuffer[i]) / 2.0;
      //--- senkou span b
      _high = Highest(high, InpSenkou, i);
      _low = Lowest(low, InpSenkou, i);
      ExtSpanBBuffer[i] = (_high + _low) / 2.0;
   }
//--- done
   return(rates_total);
}
//+------------------------------------------------------------------+


 
Soshianth Azar:

Like this:


It can be drawn with "DRAW_HISTOGRAM2".

 
Nagisa Unada #:

It can be drawn with "DRAW_HISTOGRAM2".

Hi Dear  Nagisa and thank you very much for your answer.

I'm new in MQL and Especially in the indicators. I used this method, but I did not get the correct results on this code (Red cloud was disappeared.).

I think this problem arises because this code uses the same color for both Senkou-Spans  buffers.

Do you have any suggestions or solutions for this?

Thank you again for your response and attention

We wish the best for you

Sincerely

Red Cloud disappeared.
Nagisa Unada
Nagisa Unada
  • 2021.02.04
  • www.mql5.com
Trader's profile
 

There was a mistake in my answer. The correct answer is "DRAW_COLOR_HISTOGRAM2".

In this case, a buffer is added to specify the color.

 
Nagisa Unada #:

There was a mistake in my answer. The correct answer is "DRAW_COLOR_HISTOGRAM2".

In this case, a buffer is added to specify the color.

Thank you so much Nagisa. I'll try it.

 
Hello to all.
I am trying to convert the Ichimoku indicator source code from version 4 to version 5. The code below is version 4:
//+------------------------------------------------------------------+
//|                                                     Ichimoku.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property description "Ichimoku Kinko Hyo"
#property strict

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red          // Tenkan-sen
#property indicator_color2 Blue         // Kijun-sen
#property indicator_color3 SandyBrown   // Up Kumo
#property indicator_color4 Thistle      // Down Kumo
#property indicator_color5 Lime         // Chikou Span
#property indicator_color6 SandyBrown   // Up Kumo bounding line
#property indicator_color7 Thistle      // Down Kumo bounding line
//--- input parameters
input int InpTenkan = 9; // Tenkan-sen
input int InpKijun = 26; // Kijun-sen
input int InpSenkou = 52; // Senkou Span B
//--- buffers
double ExtTenkanBuffer[];
double ExtKijunBuffer[];
double ExtSpanA_Buffer[];
double ExtSpanB_Buffer[];
double ExtChikouBuffer[];
double ExtSpanA2_Buffer[];
double ExtSpanB2_Buffer[];
//---
int    ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
{
   IndicatorDigits(Digits);
//---
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ExtTenkanBuffer);
   SetIndexDrawBegin(0, InpTenkan - 1);
   SetIndexLabel(0, "Tenkan Sen");
//---
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, ExtKijunBuffer);
   SetIndexDrawBegin(1, InpKijun - 1);
   SetIndexLabel(1, "Kijun Sen");
//---
   ExtBegin = InpKijun;
   if(ExtBegin < InpTenkan)
      ExtBegin = InpTenkan;
//---
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(2, ExtSpanA_Buffer);
   SetIndexDrawBegin(2, InpKijun + ExtBegin - 1);
   SetIndexShift(2, InpKijun);
   SetIndexLabel(2, NULL);
   SetIndexStyle(5, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(5, ExtSpanA2_Buffer);
   SetIndexDrawBegin(5, InpKijun + ExtBegin - 1);
   SetIndexShift(5, InpKijun);
   SetIndexLabel(5, "Senkou Span A");
//---
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(3, ExtSpanB_Buffer);
   SetIndexDrawBegin(3, InpKijun + InpSenkou - 1);
   SetIndexShift(3, InpKijun);
   SetIndexLabel(3, NULL);
   SetIndexStyle(6, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(6, ExtSpanB2_Buffer);
   SetIndexDrawBegin(6, InpKijun + InpSenkou - 1);
   SetIndexShift(6, InpKijun);
   SetIndexLabel(6, "Senkou Span B");
//---
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, ExtChikouBuffer);
   SetIndexShift(4, -InpKijun);
   SetIndexLabel(4, "Chikou Span");
//--- initialization done
}
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo                                               |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   int    i, k, pos;
   double high_value, low_value;
//---
   if(rates_total <= InpTenkan || rates_total <= InpKijun || rates_total <= InpSenkou)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtTenkanBuffer, false);
   ArraySetAsSeries(ExtKijunBuffer, false);
   ArraySetAsSeries(ExtSpanA_Buffer, false);
   ArraySetAsSeries(ExtSpanB_Buffer, false);
   ArraySetAsSeries(ExtChikouBuffer, false);
   ArraySetAsSeries(ExtSpanA2_Buffer, false);
   ArraySetAsSeries(ExtSpanB2_Buffer, false);
   ArraySetAsSeries(open, false);
   ArraySetAsSeries(high, false);
   ArraySetAsSeries(low, false);
   ArraySetAsSeries(close, false);
//--- initial zero
   if(prev_calculated < 1) {
      for(i = 0; i < InpTenkan; i++)
         ExtTenkanBuffer[i] = 0.0;
      for(i = 0; i < InpKijun; i++)
         ExtKijunBuffer[i] = 0.0;
      for(i = 0; i < ExtBegin; i++) {
         ExtSpanA_Buffer[i] = 0.0;
         ExtSpanA2_Buffer[i] = 0.0;
      }
      for(i = 0; i < InpSenkou; i++) {
         ExtSpanB_Buffer[i] = 0.0;
         ExtSpanB2_Buffer[i] = 0.0;
      }
   }
//--- Tenkan Sen
   pos = InpTenkan - 1;
   if(prev_calculated > InpTenkan)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++) {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpTenkan;
      while(k <= i) {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtTenkanBuffer[i] = (high_value + low_value) / 2;
   }
//--- Kijun Sen
   pos = InpKijun - 1;
   if(prev_calculated > InpKijun)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++) {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpKijun;
      while(k <= i) {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtKijunBuffer[i] = (high_value + low_value) / 2;
   }
//--- Senkou Span A
   pos = ExtBegin - 1;
   if(prev_calculated > ExtBegin)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++) {
      ExtSpanA_Buffer[i] = (ExtKijunBuffer[i] + ExtTenkanBuffer[i]) / 2;
      ExtSpanA2_Buffer[i] = ExtSpanA_Buffer[i];
   }
//--- Senkou Span B
   pos = InpSenkou - 1;
   if(prev_calculated > InpSenkou)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++) {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpSenkou;
      while(k <= i) {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtSpanB_Buffer[i] = (high_value + low_value) / 2;
      ExtSpanB2_Buffer[i] = ExtSpanB_Buffer[i];
   }
//--- Chikou Span
   pos = 0;
   if(prev_calculated > 1)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
      ExtChikouBuffer[i] = close[i];
//---
   return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
The source code below is the version converted to 5, where I've highlighted the changes:

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_plots 7
#property indicator_color1 Red          // Tenkan-sen
#property indicator_color2 Blue         // Kijun-sen
#property indicator_color3 SandyBrown   // Up Kumo
#property indicator_color4 Thistle      // Down Kumo
#property indicator_color5 Lime         // Chikou Span
#property indicator_color6 SandyBrown   // Up Kumo bounding line
#property indicator_color7 Thistle      // Down Kumo bounding line

#property indicator_style1 DRAW_LINE
#property indicator_style2 DRAW_LINE
#property indicator_style3 DRAW_HISTOGRAM, STYLE_DOT
#property indicator_style4 DRAW_HISTOGRAM, STYLE_DOT
#property indicator_style5 DRAW_LINE
#property indicator_style6 DRAW_LINE, STYLE_DOT
#property indicator_style7 DRAW_LINE, STYLE_DOT

//--- input parameters
input int InpTenkan = 9; // Tenkan-sen
input int InpKijun = 26; // Kijun-sen
input int InpSenkou = 52; // Senkou Span B
//--- buffers
double ExtTenkanBuffer[];
double ExtKijunBuffer[];
double ExtSpanA_Buffer[];
double ExtSpanB_Buffer[];
double ExtChikouBuffer[];
double ExtSpanA2_Buffer[];
double ExtSpanB2_Buffer[];
//---
int    ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
{
   IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
//---
   //SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ExtTenkanBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpTenkan - 1);
   PlotIndexSetString(0, PLOT_LABEL, "Tenkan Sen");
//---
   //SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, ExtKijunBuffer, INDICATOR_DATA);
   //SetIndexDrawBegin(1, InpKijun - 1);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpKijun - 1);
   //SetIndexLabel(1, "Kijun Sen");
   PlotIndexSetString(1, PLOT_LABEL, "Kijun Sen");
//---
   ExtBegin = InpKijun;
   if(ExtBegin < InpTenkan)
      ExtBegin = InpTenkan;
//---
   //SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(2, ExtSpanA_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);
   //SetIndexShift(2, InpKijun);
   PlotIndexSetInteger(2, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(2, PLOT_LABEL, "Senkou Span A");
   //SetIndexStyle(5, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(5, ExtSpanA2_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(5, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);
   PlotIndexSetInteger(5, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(5, PLOT_LABEL, "Senkou Span A");
//---
   //SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(3, ExtSpanB_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(3, PLOT_DRAW_BEGIN, InpKijun + InpSenkou - 1);
   PlotIndexSetInteger(3, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(3, PLOT_LABEL, "Senkou Span B");
   //SetIndexStyle(6, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(6, ExtSpanB2_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(6, PLOT_DRAW_BEGIN, InpKijun + InpSenkou - 1);
   PlotIndexSetInteger(6, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(6, PLOT_LABEL, "Senkou Span B");
//---
   //SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, ExtChikouBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(4, PLOT_SHIFT, -InpKijun);
   PlotIndexSetString(4, PLOT_LABEL, "Chikou Span");
//--- initialization done
}

No change in OnCalculate() Function.

The indicator compiles without errors or warnings, but:

1- No drawing is done on the chart.

2- The data is displayed correctly in the data window but the Senko Spans are repeated 2 times. Of course, my main problem is in understanding the lack of drawing on the chart.

I would be very grateful if you could guide me so that I know where the problems are in my work.

Sincerely

 

This is results on my chart:

This is results on my chart:

 

I fixed some pieces but now it have:

1- problem with drawing Kumo

2- when i uncomment all drawings, i get compilation warning that say : indicator buffers amount is less than needed. 

(I commented Tenkan-sen, Kijun-sen and Chiko Span because they had no problem.)

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_plots 7
#property indicator_color1 Red            // Tenkan-sen
#property indicator_color2 Blue           // Kijun-sen
#property indicator_color3 SandyBrown     // Up Kumo
#property indicator_color4 Thistle        // Down Kumo
#property indicator_color5 Lime           // Chikou Span
#property indicator_color6 SandyBrown     // Up Kumo bounding line
#property indicator_color7 Thistle        // Down Kumo bounding line

//#property indicator_type1 DRAW_LINE       // Tenkan-sen
//#property indicator_type2 DRAW_LINE       // Kijun-sen
#property indicator_type3 DRAW_HISTOGRAM2 // Up Kumo
//#property indicator_style3 STYLE_DOT      
#property indicator_type4 DRAW_HISTOGRAM2 // Down Kumo
//#property indicator_style4 STYLE_DOT
//#property indicator_type5 DRAW_LINE       // Chikou Span
#property indicator_type6 DRAW_LINE       // Up Kumo bounding line
#property indicator_type7 DRAW_LINE       // Down Kumo bounding line
//#property indicator_style7 STYLE_DOT

//--- input parameters
input int InpTenkan = 9; // Tenkan-sen
input int InpKijun = 26; // Kijun-sen
input int InpSenkou = 52; // Senkou Span B
//--- buffers
double ExtTenkanBuffer[];
double ExtKijunBuffer[];
double ExtSpanA_Buffer[];
double ExtSpanB_Buffer[];
double ExtChikouBuffer[];
double ExtSpanA2_Buffer[];
double ExtSpanB2_Buffer[];
//---
int    ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
//---
//---
   ExtBegin = InpKijun;
   if(ExtBegin < InpTenkan)
      ExtBegin = InpTenkan;

   //SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ExtTenkanBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpTenkan - 1);
   PlotIndexSetString(0, PLOT_LABEL, "Tenkan Sen");
//---
   //SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, ExtKijunBuffer, INDICATOR_DATA);
   //SetIndexDrawBegin(1, InpKijun - 1);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpKijun - 1);
   //SetIndexLabel(1, "Kijun Sen");
   PlotIndexSetString(1, PLOT_LABEL, "Kijun Sen");

//---
   //SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(2, ExtSpanA_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);
   //SetIndexShift(2, InpKijun);
   PlotIndexSetInteger(2, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(2, PLOT_LABEL, NULL);
   //SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_DOT);
   SetIndexBuffer(3, ExtSpanB_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(3, PLOT_DRAW_BEGIN, InpKijun + InpSenkou - 1);
   PlotIndexSetInteger(3, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(3, PLOT_LABEL, NULL);
   //SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, ExtChikouBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(4, PLOT_SHIFT, -InpKijun);
   PlotIndexSetString(4, PLOT_LABEL, "Chikou Span");
   //SetIndexStyle(5, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(5, ExtSpanA2_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(5, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);
   PlotIndexSetInteger(5, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(5, PLOT_LABEL, "Senkou Span A");
   //SetIndexStyle(6, DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(6, ExtSpanB2_Buffer, INDICATOR_DATA);
   PlotIndexSetInteger(6, PLOT_DRAW_BEGIN, InpKijun + InpSenkou - 1);
   PlotIndexSetInteger(6, PLOT_SHIFT, InpKijun);
   PlotIndexSetString(6, PLOT_LABEL, "Senkou Span B");
//--- initialization done

   return(INIT_SUCCEEDED);
}

Kumo 

Thank you in advanced.

 

I have rewritten it with some corrections and reorganized the content as it is very hard to understand.

#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_plots   6
//--- plot ExtTenkan
#property indicator_label1  "ExtTenkan"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot ExtKijun
#property indicator_label2  "ExtKijun"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot ExtSpanA_
#property indicator_label3  "ExtSpanA_"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrSandyBrown
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot ExtSpanB_
#property indicator_label4  "ExtSpanB_"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrThistle
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot ExtChikou
#property indicator_label5  "ExtChikou"
#property indicator_type5   DRAW_LINE
#property indicator_color5  clrLime
#property indicator_style5  STYLE_SOLID
#property indicator_width5  1
//--- plot ExtHisto_
#property indicator_label6  "ExtHisto_"
#property indicator_type6   DRAW_COLOR_HISTOGRAM2
#property indicator_color6  clrSandyBrown,clrThistle
#property indicator_style6  STYLE_DOT
#property indicator_width6  1
//--- input parameters
input int   InpTenkan  = 9;  // Tenkan-sen
input int   InpKijun   = 26; // Kijun-sen
input int   InpSenkou  = 52; // Senkou Span B
//--- indicator buffers
double         ExtTenkanBuffer[];
double         ExtKijunBuffer[];
double         ExtSpanA_Buffer[];
double         ExtSpanB_Buffer[];
double         ExtChikouBuffer[];
double         ExtHisto_Buffer1[];
double         ExtHisto_Buffer2[];
double         ExtHisto_Colors[];
int            ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
   SetIndexBuffer(0, ExtTenkanBuffer, INDICATOR_DATA);
   SetIndexBuffer(1, ExtKijunBuffer,  INDICATOR_DATA);
   SetIndexBuffer(2, ExtSpanA_Buffer, INDICATOR_DATA);
   SetIndexBuffer(3, ExtSpanB_Buffer, INDICATOR_DATA);
   SetIndexBuffer(4, ExtChikouBuffer, INDICATOR_DATA);
   SetIndexBuffer(5, ExtHisto_Buffer1, INDICATOR_DATA);
   SetIndexBuffer(6, ExtHisto_Buffer2, INDICATOR_DATA);
   SetIndexBuffer(7, ExtHisto_Colors,  INDICATOR_COLOR_INDEX);

   IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpTenkan - 1);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpKijun - 1);
   ExtBegin = InpKijun;
   if(ExtBegin < InpTenkan)
      ExtBegin = InpTenkan;
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);
   PlotIndexSetInteger(5, PLOT_DRAW_BEGIN, InpKijun + ExtBegin - 1);

   PlotIndexSetInteger(2, PLOT_SHIFT, InpKijun);
   PlotIndexSetInteger(3, PLOT_SHIFT, InpKijun);
   PlotIndexSetInteger(4, PLOT_SHIFT, -InpKijun);
   PlotIndexSetInteger(5, PLOT_SHIFT, InpKijun);
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
//---
   int    i, k, pos;
   double high_value, low_value;
//---
   if(rates_total <= InpTenkan || rates_total <= InpKijun || rates_total <= InpSenkou)
      return(0);
//--- initial zero
   if(prev_calculated < 1)
   {
      for(i = 0; i < InpTenkan; i++)
         ExtTenkanBuffer[i] = 0.0;
      for(i = 0; i < InpKijun; i++)
         ExtKijunBuffer[i] = 0.0;
      for(i = 0; i < ExtBegin; i++)
      {
         ExtSpanA_Buffer[i] = 0.0;
         ExtHisto_Buffer1[i] = 0.0;
      }
      for(i = 0; i < InpSenkou; i++)
      {
         ExtSpanB_Buffer[i] = 0.0;
         ExtHisto_Buffer2[i] = 0.0;
      }
   }
//--- Tenkan Sen
   pos = InpTenkan - 1;
   if(prev_calculated > InpTenkan)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
   {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpTenkan;
      while(k <= i)
      {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtTenkanBuffer[i] = (high_value + low_value) / 2;
   }
//--- Kijun Sen
   pos = InpKijun - 1;
   if(prev_calculated > InpKijun)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
   {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpKijun;
      while(k <= i)
      {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtKijunBuffer[i] = (high_value + low_value) / 2;
   }
//--- Senkou Span A
   pos = ExtBegin - 1;
   if(prev_calculated > ExtBegin)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
   {
      ExtSpanA_Buffer[i] = (ExtKijunBuffer[i] + ExtTenkanBuffer[i]) / 2;
   }
//--- Senkou Span B
   pos = InpSenkou - 1;
   if(prev_calculated > InpSenkou)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
   {
      high_value = high[i];
      low_value = low[i];
      k = i + 1 - InpSenkou;
      while(k <= i)
      {
         if(high_value < high[k])
            high_value = high[k];
         if(low_value > low[k])
            low_value = low[k];
         k++;
      }
      ExtSpanB_Buffer[i] = (high_value + low_value) / 2;
      ExtHisto_Buffer2[i] = ExtSpanB_Buffer[i];
      ExtHisto_Buffer1[i] = ExtSpanA_Buffer[i];
      ExtHisto_Colors[i]  = ExtSpanA_Buffer[i] > ExtSpanB_Buffer[i] ? 0 : 1;
   }
//--- Chikou Span
   pos = 0;
   if(prev_calculated > 1)
      pos = prev_calculated - 1;
   for(i = pos; i < rates_total; i++)
      ExtChikouBuffer[i] = close[i];
//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
 
Nagisa Unada #:

I have rewritten it with some corrections and reorganized the content as it is very hard to understand.

Dear Nagisa

I really appreciate your taking the time and for your help. Thank you very much for the kindness you gave me and the comprehensive and complete explanations you gave.

You are very kind and helpful. The codes you corrected are very important to me and I learned a lot from you.

I hope you are always happy and healthy and I wish you the best.

Sincerely,

With best regards.