Fractals5+Signal+diapazon_Maloma

Download script
Author: � Maloma
Fractals5+Signal+diapazon_Maloma

This script is designed as a technical analysis tool for the MetaTrader platform, specifically created to identify key structural points in price movement known as "Fractals." In trading, fractals represent local highs and lows that occur when the price reaches a peak or valley relative to the candles surrounding it.

Core Logic and Functionality

The primary purpose of this script is to scan historical price data to detect specific patterns where a single candle's high or low stands out significantly against its neighbors. Here is a breakdown of how the logic operates:

1. Multi-Pattern Detection Unlike standard indicators that only look for simple "five-candle" highs and lows, this script employs a comprehensive scanning system. It evaluates several different configurations (ranging from 5 to 9 bars in length) to identify significant turning points. This allows the tool to recognize both minor price fluctuations and more substantial structural shifts in the market.

2. High and Low Identification

  • Upward Fractals: The logic identifies "peaks" by checking if a specific candle's high price is greater than the highs of the candles preceding and following it. When this condition is met, the script marks an upward fractal point.
  • Downward Fractals: Conversely, it identifies "valleys" by checking if a candle's low price is lower than those around it. This marks a downward fractal point.

3. Visual Signaling The script provides immediate visual feedback on the trading chart through different types of markers:

  • Signal Arrows: When a fractal pattern is confirmed, the script places specific arrows (Up or Down) on the chart to alert the user to the detected price action.
  • Fractal Markers: It records the exact high or low point of the detected fractal.
  • Range Tracking (Diapazon): The script also identifies and maps out "ranges" by connecting the opening price of a candle to its respective fractal high or low. This helps in visualizing the price spread or volatility over specific periods.

4. Dynamic Scanning Logic The script performs a "backwards" scan of the chart history. It looks at every candle one by one to ensure that no structural points are missed. By accounting for various bar lengths (e.g., handling cases where multiple consecutive bars have the same high or low price), the logic ensures that the signals remain robust even in markets with "flat" tops or bottoms.

Summary for the User

In simple terms, this tool acts as an automated "scout." It constantly monitors the price history to find significant peaks and valleys. By identifying these points across various different patterns (from small local movements to larger structural changes), it highlights where the price has historically reversed direction, providing you with clear visual signals and range data to assist in your technical analysis.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Fractals5+Signal+diapazon_Maloma
//+------------------------------------------------------------------+
//|                                             Fractals5+Signal.mq4 |
//+------------------------------------------------------------------+
#property copyright "© Maloma"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 OrangeRed
#property indicator_color4 CornflowerBlue
#property indicator_color5 Magenta
#property indicator_color6 Teal
//---- input parameters
//---- buffers
double dUpFractalsBuffer[];
double dDownFractalsBuffer[];
double dUpSignalBuffer[];
double dDownSignalBuffer[];
double UpDiapazonBuffer[];
double DnDiapazonBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
   SetIndexBuffer(0,dUpFractalsBuffer);
   SetIndexBuffer(1,dDownFractalsBuffer);
   SetIndexBuffer(2,dUpSignalBuffer);
   SetIndexBuffer(3,dDownSignalBuffer);
   SetIndexBuffer(4,UpDiapazonBuffer);
   SetIndexBuffer(5,DnDiapazonBuffer);
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(0,119);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(1,119);
   SetIndexStyle(2,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(2,241);
   SetIndexStyle(3,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(3,242);
   SetIndexStyle(4,DRAW_SECTION,EMPTY,2);
   SetIndexStyle(5,DRAW_SECTION,EMPTY,2);
//----
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.0);
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0);
//---- name for DataWindow
   SetIndexLabel(0,"Fractal Up");
   SetIndexLabel(1,"Fractal Down");
   SetIndexLabel(2,"Signal Up");
   SetIndexLabel(3,"Signal Down");
   SetIndexLabel(4,"Diapazon Up");
   SetIndexLabel(5,"Diapazon 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+3+1] && High[i+3]>High[i+3+2] && High[i+3]>High[i+3-1] && High[i+3]>High[i+3-2])
        {
         dUpSignalBuffer[i]= Low[i]-3*Point;
         dUpFractalsBuffer[i+3]= High[i+3];
         UpDiapazonBuffer[i]= Open[i];
         UpDiapazonBuffer[i+3]= High[i+3];
        }
      if(Low[i+3]<Low[i+3+1] && Low[i+3]<Low[i+3+2] && Low[i+3]<Low[i+3-1] && Low[i+3]<Low[i+3-2])
        {
         dDownSignalBuffer[i]= High[i]+3*Point;
         dDownFractalsBuffer[i+3]= Low[i+3];
         DnDiapazonBuffer[i]= Open[i];
         DnDiapazonBuffer[i+3]= Low[i+3];
         i--;
         continue;
        }
      //----6 bars Fractal
      if(High[i+3]==High[i+3+1] && High[i+3]>High[i+3+2] && High[i+3]>High[i+3+3] && High[i+3]>High[i+3-1] && High[i+3]>High[i+3-2])
        {
         dUpSignalBuffer[i]= Low[i]-3*Point;
         dUpFractalsBuffer[i+3]= High[i+3];
         UpDiapazonBuffer[i]= Open[i];
         UpDiapazonBuffer[i+3]= High[i+3];
        }
      if(Low[i+3]==Low[i+3+1] && Low[i+3]<Low[i+3+2] && Low[i+3]<Low[i+3+3] && Low[i+3]<Low[i+3-1] && Low[i+3]<Low[i+3-2])
        {
         dDownSignalBuffer[i]= High[i]+3*Point;
         dDownFractalsBuffer[i+3]= Low[i+3];
         DnDiapazonBuffer[i]= Open[i];
         DnDiapazonBuffer[i+3]= Low[i+3];
         i--;
         continue;
        }
      //----7 bars Fractal
      if(High[i+3]>=High[i+3+1] && High[i+3]==High[i+3+2] && High[i+3]>High[i+3+3] && High[i+3]>High[i+3+4] && High[i+3]>High[i+3-1] &&
         High[i+3]>High[i+3-2])
        {
         dUpSignalBuffer[i]= Low[i]-3*Point;
         dUpFractalsBuffer[i+3]= High[i+3];
         UpDiapazonBuffer[i]= Open[i];
         UpDiapazonBuffer[i+3]= High[i+3];
        }
      if(Low[i+3]<=Low[i+3+1] && Low[i+3]==Low[i+3+2] && Low[i+3]<Low[i+3+3] && Low[i+3]<Low[i+3+4] && Low[i+3]<Low[i+3-1] &&
         Low[i+3]<Low[i+3-2])
        {
         dDownSignalBuffer[i]= High[i]+3*Point;
         dDownFractalsBuffer[i+3]= Low[i+3];
         DnDiapazonBuffer[i]= Open[i];
         DnDiapazonBuffer[i+3]= Low[i+3];
         i--;
         continue;
        }
      //----8 bars Fractal                          
      if(High[i+3]>=High[i+3+1] && High[i+3]==High[i+3+2] && High[i+3]==High[i+3+3] && High[i+3]>High[i+3+4] && High[i+3]>High[i+3+5] &&
         High[i+3]>High[i+3-1] && High[i+3]>High[i+3-2])
        {
         dUpSignalBuffer[i]= Low[i]-3*Point;
         dUpFractalsBuffer[i+3]= High[i+3];
         UpDiapazonBuffer[i]= Open[i];
         UpDiapazonBuffer[i+3]= High[i+3];
        }
      if(Low[i+3]<=Low[i+3+1] && Low[i+3]==Low[i+3+2] && Low[i+3]==Low[i+3+3] && Low[i+3]<Low[i+3+4] && Low[i+3]<Low[i+3+5] &&
         Low[i+3]<Low[i+3-1] && Low[i+3]<Low[i+3-2])
        {
         dDownSignalBuffer[i]= High[i]+3*Point;
         dDownFractalsBuffer[i+3]= Low[i+3];
         DnDiapazonBuffer[i]= Open[i];
         DnDiapazonBuffer[i+3]= Low[i+3];
         i--;
         continue;
        }
      //----9 bars Fractal                                        
      if(High[i+3]>=High[i+3+1] && High[i+3]==High[i+3+2] && High[i+3]>=High[i+3+3] && High[i+3]==High[i+3+4] && High[i+3]>High[i+3+5] &&
         High[i+3]>High[i+3+6] && High[i+3]>High[i+3-1] && High[i+3]>High[i+3-2])
        {
         dUpSignalBuffer[i]= Low[i]-3*Point;
         dUpFractalsBuffer[i+3]= High[i+3];
         UpDiapazonBuffer[i]= Open[i];
         UpDiapazonBuffer[i+3]= High[i+3];
        }
      if(Low[i+3]<=Low[i+3+1] && Low[i+3]==Low[i+3+2] && Low[i+3]<=Low[i+3+3] && Low[i+3]==Low[i+3+4] && Low[i+3]<Low[i+3+5] &&
         Low[i+3]<Low[i+3+6] && Low[i+3]<Low[i+3-1] && Low[i+3]<Low[i+3-2])
        {
         dDownSignalBuffer[i]= High[i]+3*Point;
         dDownFractalsBuffer[i+3]= Low[i+3];
         DnDiapazonBuffer[i]= Open[i];
         DnDiapazonBuffer[i+3]= Low[i+3];
         i--;
         continue;
        }
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments