помогите с написанием индикатора - страница 2

 
xjryensq:
Нужно переделать на MFI.

Для переделки надо брать нормальный индикатор, а не извращения больного мозга
 
Vinin:

Для переделки надо брать нормальный индикатор, а не извращения больного мозга

Значит вы не можете помочь? жаль.
 
xjryensq:

Значит вы не можете помочь? жаль.

Помочь могу
 
Vinin:

Помочь могу

Помогите пожалуйста.
 
xjryensq:

Помогите пожалуйста.

Вы можете рассказать, что вы хотите получить? Т.е. сформулировать свою задачу.
 
Integer:

Вы можете рассказать, что вы хотите получить? Т.е. сформулировать свою задачу.

Я хочу сгладить Money Flow Index.
 
Исправлять то что Вы выложили практически бесполезно. Проще написать заново
 
//+------------------------------------------------------------------+
//|                                       mfi of hull moving average |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "www.forex-tsd.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1  DeepSkyBlue 
#property indicator_width1  2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1  70
#property indicator_level2  30

//
//
//
//
//

extern string TimeFrame   = "Current time frame";
extern int    mfiPeriod   =  9;
extern int    HullPeriod  =  9;
extern int    HullPrice   = PRICE_CLOSE;
extern bool   Interpolate = true;

//
//
//
//
//

double mfi[];
double work1[];
double work2[];

//
//
//
//
//

string indicatorFileName;
bool   returnBars;
bool   calculateValue;
int    timeFrame;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(3);
      SetIndexBuffer(0,mfi);
      SetIndexBuffer(1,work1);
      SetIndexBuffer(2,work2);
   
      //
      //
      //
      //
      //
      
         indicatorFileName = WindowExpertName();
         calculateValue    = TimeFrame=="calculateValue";   if (calculateValue) { return(0); }
         returnBars        = TimeFrame=="returnBars";       if (returnBars)     { return(0); }
         timeFrame         = stringToTimeFrame(TimeFrame);
      
      //
      //
      //
      //
      //
               
   IndicatorShortName(timeFrameToString(timeFrame)+" mfi of Hull ("+mfiPeriod+","+HullPeriod+")");
   return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int HalfPeriod = MathFloor(HullPeriod/2);
   int SqrtPeriod = MathFloor(MathSqrt(HullPeriod));
   int i,limit,counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = MathMin(Bars-counted_bars,Bars-1);
         if (returnBars) { mfi[0] = MathMin(limit+1,Bars-1); return(0); }

   //
   //
   //
   //
   //

   if (calculateValue || timeFrame == Period())
   {
      for(i=limit; i>=0; i--) work1[i] = 2.0*iMA(NULL,0,HalfPeriod,0,MODE_LWMA,HullPrice,i)-iMA(NULL,0,HullPeriod,0,MODE_LWMA,HullPrice,i);
      for(i=limit; i>=0; i--) work2[i] = iMAOnArray(work1,0,SqrtPeriod,0,MODE_LWMA,i);     
      
   int    j,nCountedBars;
   double dPositiveMF,dNegativeMF,dCurrentTP,dPreviousTP;

   i = limit;
   while(i>=0)
     {
      dPositiveMF=0.0;
      dNegativeMF=0.0;
      dCurrentTP=work2[i];
      for(j=0; j<mfiPeriod; j++)
        {
         dPreviousTP=work2[i+j+1];
         if(dCurrentTP>dPreviousTP)
            dPositiveMF+=Volume[i+j]*dCurrentTP;
         else
           {
            if(dCurrentTP<dPreviousTP)
                dNegativeMF+=Volume[i+j]*dCurrentTP;
           }
          dCurrentTP=dPreviousTP;      
        }
      //----
      if(dNegativeMF!=0.0)      
         mfi[i]=100-100/(1+dPositiveMF/dNegativeMF);
      else
         mfi[i]=100;
      //----
      i--;
     }
      return(0);
   }

   //
   //
   //
   //
   //

   limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));
   for (i=limit; i>=0; i--)
   {
      int y = iBarShift(NULL,timeFrame,Time[i]);
         mfi[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",mfiPeriod,HullPeriod,HullPrice,0,y);

         //
         //
         //
         //
         //
         
            if (!Interpolate || y==iBarShift(NULL,timeFrame,Time[i-1])) continue;
            datetime time = iTime(NULL,timeFrame,y);
               for(int n = 1; i+n < Bars && Time[i+n] >= time; n++) continue;   
               for(int k = 1; k < n; k++)
                  mfi[i+k] = mfi[i] + (mfi[i+n] - mfi[i])*k/n;
   }
   return(0);         
}

//+-------------------------------------------------------------------
//|                                                                  
//+-------------------------------------------------------------------
//
//
//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
   tfs = stringUpperCase(tfs);
   for (int i=ArraySize(iTfTable)-1; i>=0; i--)
         if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period()));
                                                      return(Period());
}
string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

//
//
//
//
//

string stringUpperCase(string str)
{
   string   s = str;

   for (int length=StringLen(str)-1; length>=0; length--)
   {
      int char = StringGetChar(s, length);
         if((char > 96 && char < 123) || (char > 223 && char < 256))
                     s = StringSetChar(s, length, char - 32);
         else if(char > -33 && char < 0)
                     s = StringSetChar(s, length, char + 224);
   }
   return(s);
}

попробуйте, по-моему фигня получилась

P.S. Рассчитал MFI по значениям буфера work2 (если правильно понял, что нужно)

 
xjryensq:

Я хочу сгладить Money Flow Index.


Выглядит так, как будто хотите посчитать MFI от HullMA. Снчала надо заполнить буфер значениями MFI, а потом от этого буфера считать HullMA. Все, что связано с дургим таймфреймом надо убрать, если это будет нужно - написать второй индикатор, который будет обращаться к основному.

 
Преогромнейшее спасибо это то что нужно.