FastFractals





//+------------------------------------------------------------------+
//|                   FractalsPaint.mq4                              |
//|                Copyright © 2006  Scorpion@fxfisherman.com        |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link      "http://www.fxfisherman.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int Shift_Bars=0;
int Bars_Count= 0;

//---- buffers
double v1[];
double v2[];
  
int init()
  {

   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,v1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,v2);
   
   watermark();
 
   return(0);
  }

int start()
 {
  bool hiFractal;
  bool loFractal;
  int curFractal;
  double price;
  int i;
  int shift;
  int counted_bars = IndicatorCounted();
  if (counted_bars > 0) counted_bars--;
  if (Bars_Count > 0 && Bars_Count <= Bars)
  {
    i = Bars_Count - counted_bars;
  }else{
    i = Bars - counted_bars;
  }
  
  while(i>=0)
   {
    shift = i + Shift_Bars;
   
    // Resistance
    price = High[shift+3];
    hiFractal = price > High[shift+2] &&
              price > High[shift+1];

    // Support
    price = Low[shift+3];
    loFractal = price < Low[shift+2] &&
              price < Low[shift+1];
              
    if (hiFractal && !loFractal) {
      curFractal = -1;
    }else if(loFractal && !hiFractal) {
      curFractal = 1;
    }else if(loFractal && hiFractal){
      curFractal = 0;
    }
    
    if (curFractal == 1) {
      v2[i] = High[i];
      v1[i] = Low[i];
    }else if(curFractal == -1) {
      v1[i] = High[i];
      v2[i] = Low[i];    
    }else{
      v1[i] = Low[i];
      v2[i] = Low[i];     
    }
    
    i--;
   }   
  return(0);
 }
 
//+------------------------------------------------------------------+

void watermark()
  {
   ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
   ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
   ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
   ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
   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


Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: