Author: Copyright � 2006, SOK.LiteForEx.Net
iFractals

This script is a specialized technical analysis tool designed to identify specific price reversal patterns on your trading charts. It focuses on detecting "fractals," which are structural turning points in the market where the price shifts from an upward trend to a downward one, or vice versa.

How it Works

The logic behind this tool relies on identifying local highs and lows within a sequence of price bars. Rather than reacting to every minor fluctuation, the script looks for specific "peaks" and "valleys."

  • Upper Fractal Detection: The script scans the price history to find points where a candle's high is higher than the highs of the candles immediately preceding and following it. When this condition is met, the tool places a visual marker (a red arrow) on the chart. This typically signifies a potential ceiling or a point where upward momentum may be exhausting.
  • Lower Fractal Detection: Similarly, the script monitors for price "bottoms." It identifies points where a candle's low is lower than the lows of the candles surrounding it. When detected, it places a visual marker (a blue arrow) on the chart, suggesting a potential floor or a point where downward momentum might be reversing.

Purpose and Visualization

The primary goal of this script is to provide a clean, visual representation of market structure. Instead of requiring you to manually scan every bar for price pivots, the tool automates this process by plotting these significant levels directly on your main chart window.

By highlighting these specific reversal points, the script helps traders identify areas of support and resistance more effectively, allowing for better-informed decisions regarding potential entries or exits in the market.

Indicators Used
Fractals
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
iFractals
//+------------------------------------------------------------------+
//|                                                    iFractals.mq4 |
//|                              Copyright © 2006, SOK.LiteForEx.Net |
//|                                         http://sok.liteforex.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, SOK.LiteForEx.Net"
#property link      "http://sok.liteforex.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| 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);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("iFractals");
   SetIndexLabel(0, "iFractalsUp");
   SetIndexLabel(1, "iFractalsDn");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
//----
     int limit;
  //---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
     if(counted_bars > 0) 
         counted_bars--;
     limit = Bars - counted_bars;
  //---- îñíîâíîé öèêë
     for(int i = 2; i < limit; i++)
       {
         ExtMapBuffer1[i] = iFractals(NULL, 0, MODE_UPPER, i);
         ExtMapBuffer2[i] = iFractals(NULL, 0, MODE_LOWER, i);
       }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments