Fractals_expfx_alerts

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Fractals_expfx_alerts

This script is an automated technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to identify specific price patterns known as "Fractals" on a trading chart, which help traders visualize potential points of reversal or significant structural shifts in the market.

Core Logic and Functionality

The script operates by scanning historical price data to detect high and low peaks. Unlike standard fractal indicators that only look at immediate neighbors, this version uses an expanded logic to identify various types of price formations.

1. Identification of Price Peaks (Up Fractals)

The tool searches for "Up Fractals," which represent local price ceilings. It does this by comparing the high point of a specific candle against several candles preceding and following it. The logic checks for multiple configurations:

  • Standard Patterns: A basic peak where one candle is higher than two neighbors on each side.
  • Extended Patterns: The script automatically scales its search to identify more complex formations spanning across 6, 7, 8, and up to 9 consecutive candles. This allows the tool to capture "wider" price swings that simpler indicators might miss.

2. Identification of Price Floors (Down Fractals)

Simultaneously, the script performs the opposite analysis to find "Down Fractals," which represent local price floors. It looks for instances where a candle's low point is lower than the surrounding candles. Just as with the peaks, it utilizes an expanded multi-bar logic (6 through 9 bars) to ensure that significant bottoming patterns are captured regardless of how broadly the price moved to reach them.

3. Visual Representation

When the script identifies these specific price points, it places visual markers directly on your trading chart:

  • Upward markers are displayed to highlight potential resistance zones.
  • Downward markers are displayed to highlight potential support zones.

4. Automated Alerts

To ensure that traders do not have to watch the charts constantly, the script includes an integrated audio notification system. Whenever a new fractal pattern is confirmed on the most recent data, the tool triggers a sound alert ("alert.wav"). It is programmed with a "memory" check to ensure the sound only plays once per new bar, preventing repetitive noise.

Summary for the User

Essentially, this script acts as an automated "scout." It constantly monitors the price action to find significant structural peaks and floors. By supporting wide-range patterns (up to 9 bars), it provides a more comprehensive view of market geometry than standard tools, helping you identify where the market might be turning or consolidating.

Miscellaneous
Implements a curve of type %1It plays sound alerts
8 Views
1 Downloads
0 Favorites
Fractals_expfx_alerts
//+------------------------------------------------------------------+
//|                                      Fractals(Expforex Edit).mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//alertsalpari//  Comment("http://Expforex.at.ua");

#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_width1  2
#property indicator_width2  2
//---- input parameters

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
double Alter=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer);   
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,217);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,218);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
//---- initialization done   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//  Comment("http://Expforex.at.ua");
   int    i,nCountedBars;
   bool   bFound;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   if(nCountedBars<=2)
      i=Bars-nCountedBars-3;
   if(nCountedBars>2)
     {
      nCountedBars--;
      i=Bars-nCountedBars-1;
     }
//----Up and Down Fractals
   while(i>=2)
     {
      //----Fractals up
      bFound=false;
      dCurrent=High[i];
      if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i-1] && dCurrent>High[i-2])
        {
         bFound=true;
         ExtUpFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==High[i+1] && dCurrent>High[i+2] && dCurrent>High[i+3] &&
            dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }         
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {   
         if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent>High[i+3] && dCurrent>High[i+4] &&
            dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {   
         if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent==High[i+3] && dCurrent>High[i+4] && dCurrent>High[i+5] && 
            dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        } 
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {   
         if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent>=High[i+3] && dCurrent==High[i+4] && dCurrent>High[i+5] && 
            dCurrent>High[i+6] && dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }                                    
      //----Fractals down
      bFound=false;
      dCurrent=Low[i];
      if(dCurrent<Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i-1] && dCurrent<Low[i-2])
        {
         bFound=true;
         ExtDownFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i+3] &&
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }         
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {   
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<Low[i+3] && dCurrent<Low[i+4] &&
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {   
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent==Low[i+3] && dCurrent<Low[i+4] && dCurrent<Low[i+5] && 
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        } 
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {   
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<=Low[i+3] && dCurrent==Low[i+4] && dCurrent<Low[i+5] && 
            dCurrent<Low[i+6] && dCurrent<Low[i-1] && dCurrent<Low[i-2])
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           
           }                      
        }                                    
      i--;
     }
//----

  if (ExtDownFractalsBuffer[2]!=0&&Alter!=Time[0]){ PlaySound("alert.wav");Alter=Time[0] ;}
    if (ExtUpFractalsBuffer[2]!=0&&Alter!=Time[0]){ PlaySound("alert.wav");Alter=Time[0]; }
  return(0);
  }
//+------------------------------------------------------------------+

Comments