Индикаторы: Coffie v1 - страница 2

 
Sergey Sanin:

действительно ошибка [2016.05.22 01:20:58.185 Coffie_v1 EURUSD,M15: array out of range in 'Coffie_v1.mq4' (69,17)]

 что-то с буферами. кто знает поправьте пожалуйста. 


//+------------------------------------------------------------------+
//| CoeffofLine_v1.mq4                                               |
//| Kalenzo - Conversion only                                        |
//| I added also second line                                         |
//| bartlomiej.gorski@gmail.com                                      |
//|                                                         iCFE.mq4 |
//|              Edited by Artmedia70:                               |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot CFE1
#property indicator_label1  "CFE1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot CFE2
#property indicator_label2  "CFE2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- levels
#property indicator_level1 Silver
#property indicator_level2 Silver 

//--- input parameters
input ENUM_APPLIED_PRICE AppledPrice=PRICE_MEDIAN; // Appled price
input ENUM_MA_METHOD Method=MODE_SMMA;             // Method of smoothing
input int      Fast=5;                             // Calculated period line "Fast"
int fast;
input int      Slow=20;                            // Calculated period line "Slow"
int slow;
//--- indicator buffers
double         BufferCFE1[];
double         BufferCFE2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   fast=(Fast<1)?1:Fast;
   slow=(Slow<=fast)?fast+1:Slow;
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferCFE1);
   SetIndexBuffer(1,BufferCFE2);
   SetIndexLabel(0,"Fast");
   SetIndexLabel(1,"Slow");
   IndicatorSetString(INDICATOR_SHORTNAME,"iCFE("+IntegerToString(slow)+"/"+IntegerToString(fast)+")");
   IndicatorSetDouble(INDICATOR_LEVELVALUE,0,0.4);
   IndicatorSetDouble(INDICATOR_LEVELVALUE,1,-0.4);
//---
   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[])
  {
//---
   if(rates_total<slow) return(0);
   int limit=rates_total-prev_calculated;
   if(limit>1) limit=rates_total-slow-1;
   for(int i=limit; i>=0; i--) {
      BufferCFE1[i]=Value(fast,i,high,low);
      BufferCFE2[i]=Value(slow,i,high,low);
      }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
double Value(int period, int shift, const double &high[], const double &low[]) {
   double TYVar=0, ZYVar=0, TIndicatorVar=0, ZIndicatorVar=0, AY=0, AIndicator=0;
   for(int j=period; j>=1; j--) {
       ZYVar+=(high[shift+j-1]+low[shift+j-1])*0.5*(6-j);
       TYVar+=(high[shift+j-1]+low[shift+j-1])*0.5;
 
       ZIndicatorVar=ZIndicatorVar+iMA(NULL,0,5,3,Method,AppledPrice,shift+j-1)*(6-j);
       TIndicatorVar=TIndicatorVar+iMA(NULL,0,5,3,Method,AppledPrice,shift+j-1);

       AY=(TYVar+(55-2*ZYVar)*5/15)/15;
       AIndicator=(TIndicatorVar+(55-2*ZIndicatorVar)*5/15)/15;
      }
   return(-1000*log(AY/AIndicator));
}
//+------------------------------------------------------------------+
Причина обращения: