Скачать MetaTrader 5

iFractalOnArray

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Пиши статьи с помощью нашего редактора. Это удобно!
Михаил
1025
Михаил 2012.02.01 09:24 
как сделать такую функцию? или может есть уже такая?
Рустам
3597
Рустам 2012.02.01 10:06  
идем https://www.mql5.com/ru/code/7982 берем код индикатора и подсовываем ему свой массив вместо ценового...
Михаил
1025
Михаил 2012.02.01 12:06  
а можно пример: хотя для пары строчек
Михаил
1025
Михаил 2012.02.01 14:20  

заменил в коде high и low на close. (по скольку close также массив). но индикатор вместо 5-барных фракталов, рисует 3-х барные фрактылы. подскажите где ошибка?

//+------------------------------------------------------------------+
//|                                                     Fractals.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer);   
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,119);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,119);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
//---- initialization done   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i;
   bool   bFound;
   double dCurrent;
      int limit;
     int counted_bars=IndicatorCounted();
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
  //---- основной цикл
     for(i=2; i<limit; i++)
     {
      //----Up and Down Fractals
      //----Fractals up
      bFound=false;
      dCurrent=Close[i];
      if(dCurrent>Close[i+1] && dCurrent>Close[i+2] && dCurrent>Close[i-1] && dCurrent>Close[i-2])
        {
         bFound=true;
         ExtUpFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==Close[i+1] && dCurrent>Close[i+2] && dCurrent>Close[i+3] &&
            dCurrent>Close[i-1] && dCurrent>Close[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }         
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {   
         if(dCurrent>=Close[i+1] && dCurrent==Close[i+2] && dCurrent>Close[i+3] && dCurrent>Close[i+4] &&
            dCurrent>Close[i-1] && dCurrent>Close[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {   
         if(dCurrent>=Close[i+1] && dCurrent==Close[i+2] && dCurrent==Close[i+3] && dCurrent>Close[i+4] && dCurrent>Close[i+5] && 
            dCurrent>Close[i-1] && dCurrent>Close[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        } 
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {   
         if(dCurrent>=Close[i+1] && dCurrent==Close[i+2] && dCurrent>=Close[i+3] && dCurrent==Close[i+4] && dCurrent>Close[i+5] && 
            dCurrent>Close[i+6] && dCurrent>Close[i-1] && dCurrent>Close[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }                                    
      //----Fractals down
      bFound=false;
      dCurrent=Close[i];
      if(dCurrent<Close[i+1] && dCurrent<Close[i+2] && dCurrent<Close[i-1] && dCurrent<Close[i-2])
        {
         bFound=true;
         ExtDownFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==Close[i+1] && dCurrent<Close[i+2] && dCurrent<Close[i+3] &&
            dCurrent<Close[i-1] && dCurrent<Close[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }         
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {   
         if(dCurrent<=Close[i+1] && dCurrent==Close[i+2] && dCurrent<Close[i+3] && dCurrent<Close[i+4] &&
            dCurrent<Close[i-1] && dCurrent<Close[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {   
         if(dCurrent<=Close[i+1] && dCurrent==Close[i+2] && dCurrent==Close[i+3] && dCurrent<Close[i+4] && dCurrent<Close[i+5] && 
            dCurrent<Close[i-1] && dCurrent<Close[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        } 
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {   
         if(dCurrent<=Close[i+1] && dCurrent==Close[i+2] && dCurrent<=Close[i+3] && dCurrent==Close[i+4] && dCurrent<Close[i+5] && 
            dCurrent<Close[i+6] && dCurrent<Close[i-1] && dCurrent<Close[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }                                    
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий