Fractals5+Signal

Download script
Author: � Maloma
Fractals5+Signal

This tool is designed to identify specific price patterns on a trading chart, known as "Fractals," and provide visual cues to help traders recognize potential shifts in market momentum. By analyzing the relationship between consecutive price points, the script distinguishes between local peaks and valleys to signal significant turning points.

How the Logic Works

The core functionality of the script relies on a "five-bar" comparison logic. Instead of looking at the price in isolation, the tool examines a sequence of five candles simultaneously to determine if a specific point qualifies as a structural high or low.

Identifying Market Highs (Upward Fractals) The script monitors the highest price reached during each candle. It looks for a specific middle candle where the high is greater than the highs of the two candles preceding it and the two candles following it. When this "mountain peak" shape is confirmed, the tool identifies it as an upward fractal.

Identifying Market Lows (Downward Fractals) Similarly, the script monitors the lowest price reached during each candle. It searches for a middle candle where the low is lower than the lows of the two candles before it and the two candles after it. This "valley" shape represents a downward fractal.

Visual Feedback and Signals

To make this data actionable for a user, the script translates these mathematical findings into clear visual markers on your chart:

  • Fractal Points: These represent the actual structural highs and lows identified by the logic. They act as markers for historical price extremes.
  • Trading Signals: The script generates specific signal arrows based on these detections.
    • When an Upward Fractal is detected, a signal appears slightly below the current price point to highlight the area of interest.
    • When a Downward Fractal is detected, a signal appears slightly above the current price point.

By highlighting these specific geometric patterns in real-time, the tool helps filter out minor market "noise," allowing you to see the broader structure of the price movement more clearly.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Fractals5+Signal
//+------------------------------------------------------------------+
//|                                             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   
    IndicatorShortName("F5S");
   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