Fractals5+Signal_v1

Download script
Author: � Maloma
Fractals5+Signal_v1

This tool is designed to enhance visual price analysis by automatically identifying specific structural turning points in market data. It focuses on "Fractals," which are patterns that help traders recognize where a price trend might be reaching a peak or a valley.

Core Logic and Functionality

The script scans historical price data to locate five-bar formations where the middle bar represents a significant local extreme compared to its immediate neighbors. It distinguishes between two primary movements:

  • Upward Extremes: The logic identifies a peak by checking if the high price of a specific candle is higher than the high prices of the two candles preceding it and the two candles following it.
  • Downward Extremes: Conversely, it identifies a valley by checking if the low price of a specific candle is lower than the low prices of the two candles surrounding it on both sides.

Visual Feedback

To make this data actionable for the user, the script translates these mathematical identifications into distinct visual markers on the trading chart:

  1. Fractal Markers: These represent the actual structural points identified by the logic (the highest high or lowest low of the five-bar sequence).
  2. Signal Arrows: The tool also generates specific "Signal" indicators. When a fractal pattern is confirmed, the script places visual signals on the chart to alert the user to these zones. These are positioned slightly away from the price action—specifically placed just above downward extremes and just below upward extremes—to ensure they remain clearly visible without cluttering the primary candles.

Summary for Traders

In practical terms, this script automates the tedious task of manually hunting for price pivots. By highlighting these structural "fractals," it provides a clear visual map of support and resistance levels, helping you identify potential areas where the market momentum might shift or exhaust itself.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Fractals5+Signal_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                             Fractals5+Signal.mq4 |
//+------------------------------------------------------------------+
#property copyright "© Maloma"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 OrangeRed
#property indicator_color4 CornflowerBlue
//---- input parameters

//---- buffers
double dUpFractalsBuffer[];
double dDownFractalsBuffer[];
double dUpSignalBuffer[];
double dDownSignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,dUpFractalsBuffer);
    SetIndexBuffer(1,dDownFractalsBuffer);   
    SetIndexBuffer(2,dUpSignalBuffer);
    SetIndexBuffer(3,dDownSignalBuffer);   
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
    SetIndexArrow(0,119);
    SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
    SetIndexArrow(1,119);
    SetIndexStyle(2,DRAW_ARROW,EMPTY,2);
    SetIndexArrow(2,241);
    SetIndexStyle(3,DRAW_ARROW,EMPTY,2);
    SetIndexArrow(3,242);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
    SetIndexEmptyValue(2,0.0);
    SetIndexEmptyValue(3,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
    SetIndexLabel(2,"Signal Up");
    SetIndexLabel(3,"Signal 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,nCountedBars;
    nCountedBars=IndicatorCounted();
//---- check for possible errors
    if(nCountedBars<0 || Bars<5) return(-1);
//----
      i=Bars-nCountedBars-1;
    while(i>=0)
     {
//----Up and Down Fractals
//----5 bars Fractal
          if(High[i+3]>High[i+4] && High[i+3]>High[i+5] && High[i+3]>High[i+2] && High[i+3]>High[i+1])
            {
             dUpSignalBuffer[i]= Low[i]-3*Point;
             dUpFractalsBuffer[i+3]= High[i+3];
            }
          if(Low[i+3]<Low[i+4] && Low[i+3]<Low[i+5] && Low[i+3]<Low[i+2] && Low[i+3]<Low[i+1])
            {
              dDownSignalBuffer[i]= High[i]+3*Point;
              dDownFractalsBuffer[i+3]= Low[i+3];
            }                      
      i--;
     }

//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments