MA_SquizeMAm_mtf

Download script
Author: Kalenzo

The Squize_MA_M_mtf indicator is a specialized technical analysis tool designed for traders who need to visualize price trends while identifying periods of low volatility—often referred to as "squeezes." It achieves this by comparing two different Moving Averages (MA) and dynamically adjusting their visual representation based on the distance between them.

Core Functionality

The logic operates by calculating two independent Moving Averages with customizable periods, types (such as Exponential), and price sources. Under normal market conditions where there is a clear trend, the indicator displays these two averages independently. However, when the distance between these two averages becomes too small, the script triggers a specific "Squeeze" logic.

How the Logic Works

The indicator monitors the gap between the primary moving averages in real-time:

  • Active Trend Detection: If the difference between the two Moving Averages is larger than a user-defined threshold (the "Differential"), the indicator displays the lines normally. This allows traders to see the current direction and momentum of the market clearly.
  • Squeeze Identification: When the moving averages converge and the gap between them drops below the defined threshold, the script identifies this as a "Squeeze." Instead of letting the lines overlap or merge into a single point, the logic:
    1. Centers the main data points at the midpoint of the two averages.
    2. Generates a visual boundary (upper and lower limits) around that midpoint.
  • Visual Signaling: These boundaries act as a "zone" on your chart. When the lines are squeezed into this zone, it signals to the trader that the market is entering a period of consolidation or low volatility, which often precedes a significant breakout in price.

Multi-Timeframe Capability

A key professional feature of this script is its ability to work across different timeframes. It can pull data from higher timeframes (for example, viewing H4 trends while looking at an M15 chart). This allows traders to maintain a "big picture" perspective of the market's structural movement without having to constantly switch windows or charts.

Summary for Traders

Essentially, this indicator serves as a visual filter. It clarifies the trend when it is strong and highlights potential "coiling" moments when the market becomes stagnant. By visualizing these boundaries, it helps traders distinguish between a trending market and a market that is preparing for an imminent move.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
MA_SquizeMAm_mtf
//+------------------------------------------------------------------+
//| Squize_MA_M_mtf                                      Squize_MA.mq4 |
//| mtf:ForexTSD.com 2007                                    Kalenzo |
//| mladen's formula   ki                bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Violet
#property indicator_color4 DarkViolet
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1
#property indicator_width4 2

double upma[];
double dnma[];
double SqLup[]; 
double SqLdn[]; 

extern int MaDifrential = 5;

extern int Ma1Period = 5;
extern int Ma1Type = MODE_EMA;
extern int Ma1Price = PRICE_CLOSE;

extern int Ma2Period = 21;
extern int Ma2Type = MODE_EMA;
extern int Ma2Price = PRICE_CLOSE;

extern int     TimeFrame = 0;
extern string  note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string  IndicatorCorrectName = "MA_SquizeMAm_mtf";
extern string  note_Ind_Name = "If indicator`s Name changed - enter a New Name";

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,upma);
   SetIndexBuffer(1,dnma);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,SqLup);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(3,SqLdn);
   SetIndexStyle(3,DRAW_LINE);
   
//----
   if (TimeFrame < Period()) TimeFrame = Period();

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars1=IndicatorCounted();
   int      limit1,i1;
   if(counted_bars1 < 0) return(-1);
   limit1 = Bars-counted_bars1;
   if (TimeFrame != Period())
       {
         limit1 = MathMax(limit1,TimeFrame/Period());
         datetime TimeArray[];
        ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
            for(i1=0,int y=0; i1<limit1; i1++)
           {
              if(Time[i1]<TimeArray[y]) y++;
              upma   [i1]   = iCustom(NULL,TimeFrame,IndicatorCorrectName,0,y);
              dnma   [i1]   = iCustom(NULL,TimeFrame,IndicatorCorrectName,1,y);
               SqLup   [i1] =iCustom(NULL,TimeFrame,IndicatorCorrectName,2,y);
               SqLdn   [i1] =iCustom(NULL,TimeFrame,IndicatorCorrectName,3,y);

            }
         return(0);         
        }
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//----
   
   for(int i = 0 ;i <= limit ;i++)
   {
      double ma1 = iMA(Symbol(),0,Ma1Period,0,Ma1Type,Ma1Price,i);
      double ma2 = iMA(Symbol(),0,Ma2Period,0,Ma2Type,Ma2Price,i);       
      double madif = MathAbs(ma1-ma2);
      
      if(madif/Point > MaDifrential)
      {
         upma[i] = ma1;
         dnma[i] = ma2;
    
      }
      else
      {
         if(ma1>ma2)
         {
            upma[i] = ma1 - (madif/2);
            dnma[i] = ma1 - (madif/2);
        SqLup   [i] = ma1+ MaDifrential*Point ; 
        SqLdn   [i] = ma1 - MaDifrential*Point; 

        }
         else
         {
            upma[i] = ma2 - (madif/2);
            dnma[i] = ma2 - (madif/2);
        SqLup   [i] = ma2 + MaDifrential*Point; 
        SqLdn   [i] = ma2 - MaDifrential*Point; 
     
         }
         
      }
      
   }
   
   
      return(0);
  }
//+------------------------------------------------------------------+

Comments