Author: Copyright � 2009, Victor Chebotariov
MAFRACTALS

The MAFRACTALS indicator is designed to help traders identify significant structural turning points in the market by analyzing the relationship between price movement and a smoothed moving average. Rather than simply looking at raw price highs or lows, which can often be "noisy" or misleading, this tool focuses on detecting specific shifts in momentum.

How the Logic Works

The indicator operates by comparing the current value of a Moving Average (MA) against its values from previous periods. It specifically looks for "peaks" and "valleys" in the Moving Average's trajectory to signal potential market reversals:

  • Identifying Bearish Reversal Points (Red Arrows): The script monitors for a situation where the Moving Average has recently risen but is now beginning to curve downward. Specifically, it looks for a point where the average value was higher than the previous peak but is currently lower than the current trend line. When this "downward hook" is detected, the indicator places a red arrow at the highest price point of that specific period, suggesting a potential overhead resistance or a shift toward a downward trend.

  • Identifying Bullish Reversal Points (Blue Arrows): Conversely, the script looks for a "bottoming out" pattern in the Moving Average. It identifies moments where the average value was lower than a previous valley but is currently starting to curve upward. When this "upward hook" occurs, the indicator places a blue arrow at the lowest price point of that period, suggesting a potential support level or a shift toward an upward trend.

Key Technical Behaviors

  • Smoothing and Filtering: By using a Moving Average as the primary engine for detection (rather than raw price), the logic filters out minor market fluctuations, ensuring that only more significant structural changes are highlighted on your chart.
  • Look-back Delay: The script utilizes a "shift" parameter. This ensures that the arrows are placed accurately on confirmed historical peaks and valleys, providing a clearer visual representation of where the trend actually pivoted.
  • Visual Output: The result is a clean overhead/underhead marking system. Red arrows appear above price candles to signal potential selling opportunities or resistance, while blue arrows appear below price candles to signal potential buying opportunities or support.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
4 Views
0 Downloads
0 Favorites
MAFRACTALS
//+------------------------------------------------------------------+
//|                                                   MAFRACTALS.mq4 |
//|                             Copyright © 2009, Victor Chebotariov |
//+----[ ICQ ]-------------------------------------------------------+
//|   342-574-15                                                     |
//+----[ Phone ]-----------------------------------------------------+
//|   +380958965042                                                  |
//|   +380652707069                                                  |
//|   +380443609960                                                  |
//+----[ Web ]-------------------------------------------------------+
//|   http://chebotariov.com                                         |
//|   http://chebotariov.co.ua                                       |
//|   http://amero.com.ua                                            |
//|   http://amero.co.ua                                             |
//|   http://investmoney.kiev.ua                                     |
//|   http://riskinvest.kiev.ua                                      |
//|   http://tetrabourse.com.ua                                      |
//|   http://tb-unitrade.com.ua                                      |
//|   http://i-contact.kiev.ua                                       |
//|   http://srubidom.com                                            |
//+----[ E-mail ]----------------------------------------------------+
//|   victor@chebotariov.co.ua                                       |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Victor Chebotariov"
#property link      "http://www.chebotariov.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int period=14;
extern int shift=4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(0,234);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(1,233);
   SetIndexBuffer(1,ExtMapBuffer2);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| MAFRACTALS                                                       |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      if(shift<3)
         {
            shift=3;
         }
      double ma = iMA(NULL,0,period,0,0,0,i);
      double ma1 = iMA(NULL,0,period,0,0,0,i+shift);
      double ma2 = iMA(NULL,0,period,0,0,0,i+shift*2-1);
      
      if(ma<ma1 && ma1>ma2)
         {
            ExtMapBuffer1[i+shift] = High[i+shift];
         }
      if(ma>ma1 && ma1<ma2)
         {
            ExtMapBuffer2[i+shift] = Low[i+shift];
         }

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

Comments