fractal_2lev

Download script
Author: Copyright � 2006, HexSys
fractal_2lev

This script is designed as a visual tool for trading platforms to identify specific price patterns on a chart. Its primary goal is to highlight significant structural "peaks" and "valleys" in market movement, helping traders recognize potential reversal points or trend changes.

Core Mechanics

The logic operates in two distinct layers to filter out minor market noise and focus on significant price extremes:

1. Initial Pattern Identification (Primary Fractals) The tool first scans the most recent history of price bars (specifically looking at 100 bars by default). It identifies "Fractals," which are simple local highs and lows.

  • A High Fractal is identified when a candle's high point is higher than the candles immediately preceding it and following it.
  • A Low Fractal is identified when a candle's low point is lower than those surrounding it.

2. Secondary Filtering (Nested Fractals) The script doesn't stop at the first layer of identification. It performs a second pass over the data to look for "Fractals within Fractals." This means it examines the sequence of primary highs and lows to find more significant turning points.

  • It keeps track of the positions of the most recent high and low points.
  • It then checks if a previous point was higher (or lower) than both the one before it and the one after it in the sequence of identified peaks.
  • This double-filtering ensures that only the most prominent structural points are highlighted, rather than every minor fluctuation in price.

Visual Representation

The script communicates these findings using specific markers on the chart:

  • Upper Markers: These represent significant resistance levels or "peaks" where the price has hit a local ceiling and started to turn back down.
  • Lower Markers: These represent significant support levels or "valleys" where the price has hit a local floor and started to bounce back up.

By isolating these multi-layered structural points, the tool allows a user to see the "skeleton" of the market trend more clearly, filtering out the minor "wiggles" of everyday price movement.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
fractal_2lev
//+------------------------------------------------------------------+
//|                                                 fractal_2lev.mq4 |
//|                                         Copyright © 2006, HexSys |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, HexSys"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DimGray
#property indicator_color2 DimGray
#property indicator_color3 Red
#property indicator_color4 Blue
//---- input parameters
extern int       BARS=100;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,217);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,218);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=BARS;//IndicatorCounted();
//----
   for(int i=1;i<BARS;i++)
   {
      if (High[i]>High[i+1] && High[i]>High[i-1]) ExtMapBuffer1[i]=High[i];
      if (Low[i]<Low[i+1] && Low[i]<Low[i-1]) ExtMapBuffer2[i]=Low[i];
   }
   
   int h1=0,h2=0,h3=0,ht=0;
   int l1=0,l2=0,l3=0,lt=0;
   
   for(i=1;i<BARS;i++)
   {
      if(ExtMapBuffer1[i]!=0)
      {
         h3=h2; h2=h1; h1=i;
         if (High[h2]>High[h3] && High[h2]>High[h1]) ExtMapBuffer3[h2]=High[h2];
      }
      if(ExtMapBuffer2[i]!=0)
      {
         l3=l2; l2=l1; l1=i;
         if (Low[l2]<Low[l3] && Low[l2]<Low[l1]) ExtMapBuffer4[l2]=Low[l2];
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments