wlxFractals_v3

Author: Copyright � 2004, by wellx
wlxFractals_v3

This tool is designed to identify specific price結構 patterns known as "Fractals" on a trading chart. In simple terms, it automatically scans historical price data to pinpoint local peaks and valleys, marking them with visual symbols so that traders can more easily identify potential support and resistance levels.

Core Logic and Functionality

The script functions by analyzing the relationship between a specific price candle and the candles immediately surrounding it. Instead of just looking for the highest or lowest point in isolation, it validates these points based on a set of customizable rules:

1. Identifying Price Peaks (Upper Fractals) To identify an upper fractal (a local high), the script looks for a candle where the "High" price is higher than a specific number of candles to its left and to its right. It ensures that the middle candle stands out as a significant peak relative to its neighbors, allowing traders to spot areas where upward momentum may be stalling.

2. Identifying Price Valleys (Lower Fractals) Similarly, to identify a lower fractal (a local low), the script scans for candles where the "Low" price is lower than those around it. This highlights significant dips in the market, which can indicate potential zones where the price might find a floor and begin to bounce back up.

3. Customization Controls The logic includes several adjustable parameters that allow users to define how "strict" the identification process should be:

  • Left/Right Sensitivity: You can choose how many candles to the left and right of a point must be lower (for peaks) or higher (for valleys) for a fractal to be confirmed.
  • Equality Handling: The script includes logic to handle instances where multiple adjacent candles have the exact same high or low price, ensuring that the most significant point is captured accurately even in "flat" market movements.

How it appears on your chart

Once the logic completes its scan of the historical data, it places two distinct types of arrows on the chart:

  • Upper Arrows: These mark the identified peaks (top of price swings).
  • Lower Arrows: These mark the identified valleys (bottom of price swings).

By providing these clear visual markers, the script helps traders filter out "market noise" and focus on significant structural turning points in the price action.

Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
wlxFractals_v3
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                  wlxFractals.mq4 |
//|         Copyright © 2004, by konKop, GOODMAN, Mstera, af + wellx |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by wellx"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
//---- input parameters
extern int       Equals=5;
extern int       nLeftUp=2;
extern int       nRightUp=2;
extern int       nLeftDown=2;
extern int       nRightDown=2;
//---- buffers
double FractalsUp[];
double FractalsDown[];

int pos=0, cntup=0, cntdown=0, cnt=0;
int r=0,l=0,e=0;
int fup=0,fdown=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,FractalsUp);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,FractalsDown);
   SetIndexEmptyValue(1,0.0);
   
   cntup=nLeftUp+nRightUp+Equals+1;
   cntdown=nLeftDown+Equals+1;
   if (cntup>=cntdown) cnt=cntup;
   if (cntup<cntdown)  cnt=cntdown; 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i=0, j=0;
   int cbars=IndicatorCounted();
   if  (cbars<0) return(-1);
   if  (cbars>0) cbars--;
   
   pos=0;
    
   if (cbars > (Bars-cnt-1)) pos=(Bars-cnt-1);
   else pos=cbars+nRightUp;
      
   while (pos>=nRightUp)
    {
     FractalsUp[pos]  =NULL;
     FractalsDown[pos]=NULL;
     
     //ôÐÀÊÒÀË ÂÂÅÐÕ
     r=nRightUp; //ïðîâåðÿåì ïðàâóþ ñòîðîíó ôðàêòàëà
     for (i=1;i<=r;i++)
     {
      if (High[pos]<=High[pos-i]) break;
     }
     
     //åñëè ñïðàâà âñå ÎÊ òî i äîëæíî áûòü ðàâíî r+1
     if (i==r+1) //FractalsUp[pos]=High[pos];
     {
      l=nLeftUp;  //ïðîâåðÿåì ëåâóþ ñòîðîíó ôðàêòàëà
      e=Equals;
      for (j=1;j<=l+Equals;j++)
       {
      
        if (High[pos] < High[pos+j]) break;
        if (High[pos] > High[pos+j]) l--;
        if (High[pos] == High[pos+j])e--;
        if (l==0) 
         {
           FractalsUp[pos]=High[pos];
           break;
         }
        if (e<0) break;
       }
     }
     
     //ÔÐÀÊÒÀË ÂÍÈÇ
     r=nRightDown; //ïðîâåðÿåì ïðàâóþ ñòîðîíó ôðàêòàëà
     for (i=1;i<=r;i++)
     {
      if (Low[pos]>=Low[pos-i]) break;
     }  
   
     if (i==r+1) //FractalsUp[pos]=High[pos];
     {
      l=nLeftDown;  //ïðîâåðÿåì ëåâóþ ñòîðîíó ôðàêòàëà
      e=Equals;
      for (j=1;j<=l+Equals;j++)
       {
      
        if (Low[pos] > Low[pos+j]) break;
        if (Low[pos] < Low[pos+j]) l--;
        if (Low[pos] == Low[pos+j])e--;
        if (l==0) 
         {
           FractalsDown[pos]=Low[pos];
           break;
         }
        if (e<0) break;
       }
     }
    pos--;
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments