New_Fractals_Lines





//+------------------------------------------------------------------+
//|                                           New_Fractals_Lines.mq4 |
//|                                      Copyright © -2007, olyakish |
//|                                           plutonia-dmb#yandex.ru |
//+------------------------------------------------------------------+
#property copyright "olyakish"
#property link "plutonia-dmb#yandex.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green // Ïðèñåäàþùèé
#property indicator_color2 Red   // Ïðèñåäàþùèé
//----
extern int			Pips		= 5;
double ExtGreenBuffer[];
double ExtRedBuffer[];
double AllHLDown, AllVolDown, AllHLUp, AllVolUp, AllMFIDown, AllMFIUp;
int OldFractal = 2;
bool Up = false, Down = false;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexShift(0, 0);
   SetIndexShift(1, 0);
//----
   SetIndexBuffer(0, ExtGreenBuffer);
   SetIndexBuffer(1, ExtRedBuffer);
//----
   SetIndexStyle(0, DRAW_ARROW, 0, 1);
   SetIndexStyle(1, DRAW_ARROW, 0, 1);
//----
   SetIndexArrow(0, 177);
   SetIndexArrow(1, 177);
//----
   ObjectCreate("Up", OBJ_TREND, 0, iTime(NULL, 0, 2), High[2], 
                iTime(NULL, 0, 1), High[1],0,0);
   ObjectSet("Up", OBJPROP_COLOR, Blue);
   ObjectSet("Up", OBJPROP_RAY, true);
//----   
   ObjectCreate("Down", OBJ_TREND, 0, iTime(NULL, 0, 2), Low[2], 
                iTime(NULL, 0, 1), Low[1],0,0);
   ObjectSet("Down", OBJPROP_COLOR, Brown);
   ObjectSet("Down", OBJPROP_RAY, true);             
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Up");
   ObjectDelete("Down");
   return(0);
  }        
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {  
   ArrayInitialize(ExtGreenBuffer, NULL);
   ArrayInitialize(ExtRedBuffer, NULL);
   for(int i = 100; i >= 3; i--)
     {
       // íàñ èíòåðåñóåò òîëüêî ñèòóàöèÿ êîãäà íà áàðå îäèí ôðàêòàë 
       // (â ëþáóþ ñòîðîíó)
       // åñëè äâà ôðàêòàëà íà îäíîì áàðå òî îòñåèâàåì òàêèå ñèòóàöèè
       if(iFractals(NULL, 0, MODE_UPPER, i) != 0)
         {
           Up = true;
           Down = false;   
         }
       if(iFractals(NULL, 0, MODE_LOWER, i) != 0)
         {
           Up = false;
           Down = true;
         }
       // äâà ôðàêòàëà ñðàçó - èãíîðèðóåì
       if(iFractals(NULL, 0, MODE_UPPER, i) != 0 &&
          iFractals(NULL, 0, MODE_LOWER,i) != 0) 
         {
           Up = false;   
           Down = false;    
         }
       // íà òåêóùåì áàðå åñòü ôðàêòàë âíèç 
       if(Up == false && Down ==true)   
         {
           AllHLDown = 0;
           AllVolDown = 0;
           AllHLDown = High[i+2] - Low[i+2] + High[i+1] - Low[i+1] + 
                       High[i] - Low[i] + High[i-1] - Low[i-1] + 
                       High[i-2] - Low[i-2];
           AllVolDown = Volume[i+2] + Volume[i+1] + Volume[i] + 
                        Volume[i-1] + Volume[i-2];
           AllMFIDown = AllHLDown / AllVolDown;
           // ïðåäûäóùèé ôðàêòàë áûë ââåðõ - ñðàâíèâàåì äâà ôðàêòàëà 
           // (ââåðõ è òåêóùèé âíèç)
           if(OldFractal ==1 ) 
             {
               // èìååì ïðèñåäàþùèé ôðàêòàë (MFI - îáúåì +)
               if(AllMFIDown < AllMFIUp && AllVolDown > AllVolUp) 
                 {
                   // çàïîëíÿåì áóôåðû
                   ExtGreenBuffer[i] = NULL;
                   ExtRedBuffer[i] = Low[i]; // - Pips*Point;

                 }
             }
           OldFractal = 0;
         }
       // íà òåêóùåì áàðå åñòü ôðàêòàë ââåðõ 
       if(Up == true && Down == false)  
         {
           AllHLUp = 0;
           AllVolUp = 0;
           AllHLUp = High[i+2] - Low[i+2] + High[i+1] - Low[i+1] + 
                     High[i] - Low[i] + High[i-1] - Low[i-1] + 
                     High[i-2] - Low[i-2];
           AllVolUp = Volume[i+2] + Volume[i+1] + Volume[i] + 
                      Volume[i-1] + Volume[i-2];
           AllMFIUp = AllHLUp / AllVolUp;
           // ïðåäûäóùèé ôðàêòàë áûë âíèç - ñðàâíèâàåì äâà ôðàêòàëà 
           // (ââåðõ è òåêóùèé âíèç)
           if(OldFractal == 0) 
             {
               // èìååì ïðèñåäàþùèé ôðàêòàë (MFI - îáúåì +)
               if(AllMFIUp < AllMFIDown && AllVolUp > AllVolDown) 
                 {
                   // çàïîëíÿåì áóôåðû
                   ExtGreenBuffer[i] = High[i]; // + Pips*Point;
                   ExtRedBuffer[i] = NULL;

                 }
             }
           OldFractal=1;
         }    
     } 
   double _Price[2,2];
   int  _Time[2,2];
   ArrayInitialize(_Price, -1);
   ArrayInitialize(_Time, -1);
//----
   for(i = 3; i <= 100; i++)
     {
       //up
       if(ExtGreenBuffer[i] != NULL && _Price[0,0] != -1 && _Price[1,0] == -1)
         {
           _Price[1,0] = ExtGreenBuffer[i];
           _Time[1,0] = iTime(NULL, 0, i);         
         }
       if(ExtGreenBuffer[i] != NULL && _Price[0,0] == -1)
         {
           _Price[0,0] = ExtGreenBuffer[i];
           _Time[0,0] = iTime(NULL, 0, i);
         }
       // down 
       if(ExtRedBuffer[i] != NULL && _Price[0,1] != -1 && _Price[1,1] == -1)
         {
           _Price[1,1]=ExtRedBuffer[i];_Time[1,1]=iTime(NULL, 0, i);         
         } 
       if (ExtRedBuffer[i]!=NULL && _Price[0,1]==-1)
          {
          _Price[0,1]=ExtRedBuffer[i];_Time[0,1]=iTime(NULL, 0, i);
           }        
     }
   ObjectMove("Up", 1, _Time[0,0], _Price[0,0]);
   ObjectMove("Up", 0, _Time[1,0], _Price[1,0]);
   ObjectMove("Down", 1, _Time[0,1], _Price[0,1]);
   ObjectMove("Down", 0, _Time[1,1], _Price[1,1]);
   return(0);
  }
//+------------------------------------------------------------------+







Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains tick volumes of each bar
Series array that contains open time of each bar


Indicator Curves created:


Implements a curve of type DRAW_ARROW

Indicators Used:

Fractals


Custom Indicators Used:

Order Management characteristics:

Other Features: