Author: � Maloma
SignalBars

The Signal Bars indicator is designed to identify specific structural turning points in market price action by detecting "fractals"—patterns where the price reaches a local peak or valley relative to its immediate surroundings.

Instead of relying on simple moving averages or oscillators, this script analyzes the relationship between consecutive price candles to pinpoint significant structural shifts. Here is a breakdown of the logic:

Core Methodology: Fractal Detection

The tool scans the price history to find specific "High" and "Low" points. For a point to be considered a valid signal, it must stand out as a peak (higher than its neighbors) or a valley (lower than its neighbors).

The script is particularly sophisticated because it does not look for just one type of pattern; it scans for multiple variations based on the number of surrounding bars involved:

  • Standard Patterns: It identifies basic peaks and valleys where a single candle clearly stands out above or below the four candles adjacent to it.
  • Extended Patterns: The logic expands to account for more complex market structures. It can identify patterns spanning 6, 7, 8, and even 9 consecutive bars. This allows the indicator to remain sensitive to minor price fluctuations while also capturing much larger, more significant structural turns in the market.

How the Signals are Processed

When the script successfully identifies one of these multi-bar structures, it performs several actions simultaneously:

  1. Signal Identification: It marks a "Signal Up" or "Signal Down" point. These act as visual cues on your chart to indicate where the market has transitioned from a bullish to a bearish trend (or vice versa).
  2. Fractal Mapping: It records the exact high or low price of the peak/valley, providing a clear reference point for historical price extremes.
  3. Range Identification (Diapazon): The logic captures the relationship between the opening price and the identified fractal high/low. This helps in defining the "range" or boundaries of a specific price movement, allowing you to see how much ground the market covered during that specific structural shift.

User Experience Summary

For a trader, this means the indicator filters out "market noise." Rather than providing a signal on every minor tick, it waits for the price to complete a recognizable geometric structure (a fractal). By identifying these peaks and valleys across various bar lengths, it provides a comprehensive view of market structure, highlighting both major trend reversals and smaller corrective movements.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SignalBars
//+------------------------------------------------------------------+
//|                                                  Signal Bars.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_NONE,EMPTY,2);
    SetIndexArrow(0,119);
    SetIndexStyle(1,DRAW_NONE,EMPTY,2);
    SetIndexArrow(1,119);
    SetIndexStyle(2,DRAW_ARROW,EMPTY,3);
    SetIndexArrow(2,119);
    SetIndexStyle(3,DRAW_ARROW,EMPTY,3);
    SetIndexArrow(3,119);
    SetIndexStyle(4,DRAW_NONE,EMPTY,2);
    SetIndexStyle(5,DRAW_NONE,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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             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]= Open[i+1];
             dDownFractalsBuffer[i+3]= Low[i+3];
             DnDiapazonBuffer[i]= Open[i];
             DnDiapazonBuffer[i+3]= Low[i+3];
             i--;
             continue;
            }                        
      i--;
     }

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

Comments