Please Help

 

I am trying to modify this indicator coded by Wozniak but I have failed to add two more key buffers. How should I do this?

//+------------------------------------------------------------------+
//|                                              FisherTransform.mq5 |
//|                                                                  |
//| Fisher Transform                                                 |
//|                                                                  |
//| Algorithm taken from book                                        |
//|     "Cybernetics Analysis for Stock and Futures"                 |
//| by John F. Ehlers                                                |
//|                                                                  |
//+------------------------------------------------------------------+
//---- author of the indicator
#property copyright "Coded by Witold Wozniak"
//---- indicator version
#property version   "1.10"
//---- drawing the indicator in a separate window
#property indicator_separate_window
//---- two buffers are used for calculation and drawing the indicator
#property indicator_buffers 4
//---- two plots are used
#property indicator_plots   2
//+----------------------------------------------+
//|  Fisher indicator drawing parameters         |
//+----------------------------------------------+
//---- drawing indicator 1 as a line
#property indicator_type1   DRAW_LINE
//---- red color is used as the color of the indicator line
#property indicator_color1  clrYellow
//---- the indicator 1 line is a continuous curve
#property indicator_style1  STYLE_SOLID
//---- indicator 1 line width is equal to 1
#property indicator_width1  1
//---- displaying the indicator line label
#property indicator_label1  "Fisher"
//+----------------------------------------------+
//|  Trigger indicator drawing parameters        |
//+----------------------------------------------+
//---- drawing the indicator 2 as a line
#property indicator_type2   DRAW_LINE
//---- blue color is used for the indicator line
#property indicator_color2  clrBlue
//---- the indicator 2 line is a continuous curve
#property indicator_style2  STYLE_SOLID
//---- indicator 2 line width is equal to 1
#property indicator_width2  1
//---- displaying the indicator line label
#property indicator_label2  "Trigger"
//+----------------------------------------------+
//| Horizontal levels display parameters         |
//+----------------------------------------------+
#property indicator_level1 0.0
#property indicator_levelcolor clrGray
#property indicator_levelstyle STYLE_DASHDOTDOT
//+----------------------------------------------+
//|  Indicator input parameters                  |
//+----------------------------------------------+
input int Length=10;  // Indicator period 
input int Shift=0;    // Horizontal shift of the indicator in bars 
//+----------------------------------------------+
//---- declaration of dynamic arrays that
//---- will be used as indicator buffers
double FisherBuffer[];
double TriggerBuffer[];
double PassBuffer[];
double FilterBuffer[];
double _alpha,_a1,_b1,_c1,_c2,_c3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+  
void OnInit()
  {
//---- set FisherBuffer[] dynamic array as an indicator buffer
   SetIndexBuffer(0,FisherBuffer,INDICATOR_DATA);
//---- shifting the indicator 1 horizontally by Shift
   PlotIndexSetInteger(0,PLOT_SHIFT,Shift);
//---- performing shift of the beginning of counting of drawing the indicator 1 by Length
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,Length);

//---- set TriggerBuffer[] dynamic array as an indicator buffer
   SetIndexBuffer(1,TriggerBuffer,INDICATOR_DATA);
//---- shifting the indicator 2 horizontally by Shift
   PlotIndexSetInteger(1,PLOT_SHIFT,Shift);
//---- performing shift of the beginning of counting of drawing the indicator 2 by Length
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,Length);

//---- set PassBuffer[] dynamic array as an indicator buffer
   SetIndexBuffer(2,PassBuffer,INDICATOR_CALCULATIONS);
//---- shifting the indicator 3 horizontally by Shift
   PlotIndexSetInteger(2,PLOT_SHIFT,Shift);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,Length);
   
//---- set FilterBuffer[] dynamic array as an indicator buffer
   SetIndexBuffer(3,FilterBuffer,INDICATOR_CALCULATIONS);
//---- shifting the indicator 4 horizontally by Shift
   PlotIndexSetInteger(3,PLOT_SHIFT,Shift);
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,Length);
   
//---- initializations of a variable for the indicator short name
   string shortname;
   StringConcatenate(shortname,"FisherTransform(",Length,", ",Shift,")");
//---- creating a name for displaying in a separate sub-window and in a tooltip
   IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//---- determination of accuracy of displaying the indicator values
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//----
   double _pi=3.141592653589793;
   _alpha=(MathCos(MathSqrt(0.5)*360/48.0)+MathSin(MathSqrt(0.5)*360/48.0)-1.0)/MathCos(MathSqrt(0.5)*360/48.0); 
   _a1 = MathExp(-1.0*MathSqrt(2.0)*_pi/10.0);
   _b1 = 2.0*_a1*MathCos(MathSqrt(2.0)*180/10.0); 
   _c2 = _b1;
   _c3 = (-1.0*_a1)*_a1;
   _c1 = 1.0-_c2-_c3;
   
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,    // number of bars in history at the current tick
                const int prev_calculated,// number of bars calculated at previous call
                const datetime &time[],
                const double &open[],
                const double& high[],     // price array of maximums of price for the indicator calculation
                const double& low[],      // price array of minimums of price for the indicator calculation
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---- checking the number of bars to be enough for the calculation
   if(rates_total<Length) return(0);

//---- declarations of local variables 
   int first,bar,kkk;
   double price,price1,MaxH,MinL,Value;
   static double Value_;

//---- calculation of the 'first' starting index for the bars recalculation loop
   if(prev_calculated>rates_total || prev_calculated<=0) // checking for the first start of the indicator calculation
     {
      first=Length-1; // starting index for calculation of all bars
      Value_=0.0;
     }
   else first=prev_calculated-3; // starting index for calculation of new bars

//---- restore values of the variables
   Value=Value_;

//---- main indicator calculation loop
   for(bar=first; bar<rates_total; bar++)
     {
      //---- store values of the variables before running at the current bar
      if(rates_total!=prev_calculated && bar==rates_total-1)
         Value_=Value;

      price=(high[bar]+low[bar])/2.0;
      MaxH = price;
      MinL = price;

      for(int iii=0; iii<Length; iii++)
        {
         kkk=bar-iii;
         price1=(high[kkk]+low[kkk])/2.0;
         if(price1 > MaxH) MaxH = price1;
         if(price1 < MinL) MinL = price1;
        }

      double res=MaxH-MinL;
      if(res) Value=0.5*2.0 *((price-MinL)/res-0.5)+0.5*Value;
      else Value=0.0;

      if(Value>+0.9999) Value=+0.9999;
      if(Value<-0.9999) Value=-0.9999;

      //MY CHANGES ARE HERE

      PassBuffer[bar]=(MathPow(1.0-_alpha/2.0,2.0)*(FisherBuffer[bar]-(2.0*FisherBuffer[bar-1])+FisherBuffer[bar-2]))+(2.0*(1.0-_alpha)*PassBuffer[bar-1])-(MathPow(1.0-_alpha,2.0)*PassBuffer[bar-2]);
      FilterBuffer[bar]=(_c1*(PassBuffer[bar]+PassBuffer[bar-1])/2.0)+(_c2*FilterBuffer[bar-1])+(_c3*FilterBuffer[bar-2]);
      
      FisherBuffer[bar]=0.25*MathLog((1+Value)/(1-Value))+0.5*FisherBuffer[bar-1];
      TriggerBuffer[bar]=FilterBuffer[bar];//FisherBuffer[bar-1]     }
//----     
   return(rates_total);
  }
//+------------------------------------------------------------------+

 Any help will be greatly appreciated.

 

Assuming that you want to plot the new lines you have to declare them.

As a fragment what has to have changed and added: (It is necessary to read the documentation to understand what is needed to modify or create code)

#property indicator_plots   4
//---- drawing indicator 1 as a line
#property indicator_type3   DRAW_LINE
//+----------------------------------------------+
#property indicator_type4   DRAW_LINE 
 
ugo58:

Assuming that you want to plot the new lines you have to declare them.

As a fragment what has to have changed and added: (It is necessary to read the documentation to understand what is needed to modify or create code)

Sorry I was mis-understood. I actually want to replace an existing buffer (the trigger buffer) with values calculated from 2 new buffers...