Fractals5+Signal_v2

Download script
Author: � Maloma
Fractals5+Signal_v2

This technical tool is designed to identify specific price action patterns on a trading chart by analyzing the relationship between consecutive price points. It serves as a visual guide to help traders spot potential turning points in market momentum by highlighting "Fractals."

Core Logic and Identification

The script scans the price history to locate two distinct types of peaks and valleys:

  • Upper Fractals (Resistance Points): The tool looks for a specific five-bar sequence where a single high point stands out as being higher than the two candles immediately preceding it and the two candles immediately following it. When this condition is met, the tool identifies a local "peak."
  • Lower Fractals (Support Points): Conversely, the tool searches for a five-bar sequence where a single low point is lower than the two candles before it and the two candles after it. This identifies a local "valley" or floor in the price action.

Visual Execution

Rather than just calculating numbers in the background, the script provides real-time visual feedback on your trading screen through two different types of markers:

  1. Fractal Markers: These represent the actual high or low points where the pattern was confirmed. They act as historical markers for significant price structure.
  2. Signal Markers: When a fractal is detected, the script automatically generates a visual signal (an arrow) on the chart.
    • For Upward Signals, the marker is placed slightly below the current price to indicate where an upward structural point has been established.
    • For Downward Signals, the marker is placed slightly above the current price to indicate where a downward structural point has been established.

Summary for Traders

In simple terms, this script automates the tedious process of manually checking every candle to see if it forms a "mountain top" or a "valley floor." It filters out minor market noise and only plots markers when a clear, five-bar price structure is completed, allowing you to see significant support and resistance levels more clearly on your charts.

Miscellaneous
Implements a curve of type %1
5 Views
0 Downloads
0 Favorites
Fractals5+Signal_v2
//+------------------------------------------------------------------+
//|                                             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