MTF_Resistance_Support

Download script
Author: StarLimit Software Corp.
MTF_Resistance_Support

This script is designed to provide traders with a visual representation of key price levels, specifically identifying Support and Resistance zones across multiple timeframes simultaneously. Instead of looking at just one chart timeframe, this tool analyzes historical data from three different time horizons to help identify "strong" price areas where the market might react or reverse.

Core Logic and Functionality

1. Multi-Timeframe Analysis (MTF) The primary strength of this script is its ability to "look ahead" at larger timeframes while you are viewing a smaller one. It automatically selects three distinct timeframes based on your current view:

  • Low Timeframe: For immediate, short-term price action.
  • Own Timeframe: The current chart you are looking at.
  • High Timeframe: For identifying long-term major trends and significant barriers.

If the "Autoset" feature is active, the script intelligently pairs these timeframes (for example, if you are on a 15-minute chart, it might automatically analyze the 5-minute, 15-minute, and 1-hour charts).

2. Identifying Support and Resistance The script uses a mathematical method called "Fractals" to identify significant peaks and valleys in price history.

  • Resistance (Red Markers): These represent "ceilings" where the price has struggled to move higher. The script tracks the highest points reached during price fluctuations.
  • Support (Blue Markers): These represent "floors" where the price has found a base and struggled to drop lower. The script tracks the lowest points reached.

3. Dynamic Level Tracking The logic is built to be "persistent." If no new fractal (peak or valley) is detected on a specific timeframe, the script remembers and carries forward the last known significant level. This ensures that the support and resistance lines stay visible and relevant on your chart until a new, stronger price action point is established.

4. Visual Alerts and Information The script provides several ways to interpret this data:

  • Visual Markers: It plots dots or arrows on the chart to highlight these key levels clearly.
  • On-Screen Summary: If enabled, it displays a text box on your chart showing the exact numerical values of the most recent high and low points for all three analyzed timeframes, along with the current Ask and Bid prices.
  • Vertical Lines (Optional): There is a specific logic included to draw vertical lines on the chart when price levels from different timeframes align perfectly. This identifies "Confluence"—points where multiple timeframes agree on a support or resistance level, which are often considered high-probability areas for traders.

Summary for the Trader

Essentially, this tool acts as a multi-layered radar. It filters out the "noise" of minor price movements by highlighting only the significant structural boundaries found across three different time horizons. It helps you see not just where the price is now, but where it has historically struggled to go in the past, providing a clearer picture of the market's "geography."

Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each barSeries array that contains open prices of each bar
Indicators Used
Fractals
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
MTF_Resistance_Support
//+------------------------------------------------------------------+
//|                                       MTF_Resistance&Support.mq4 |
//|                                         StarLimit Software Corp. |
//|                                            starlimit03@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "StarLimit Software Corp."
#property link      "starlimit03@yahoo.com"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
#property indicator_color5 Red
#property indicator_color6 Blue

//---- buffers
double mabel01[],mabel02[],mabel11[],mabel12[],mabel21[],mabel22[];

int shift[3],per[3];
extern bool showinfo=false;
extern bool autoset=true;
extern bool showlines=false;
extern int TimeFrame1=0,TimeFrame2=0,TimeFrame3=0;
double mabel1;
double mabel2;
int i,h;
double high0,high1,high2,low0,low1,low2;
 string auto =" FALSE";
string last="exit";
bool first=true;
int init()
  {
//---- indicators
   //----
  IndicatorBuffers(6);
 
//---- drawing settings
 SetIndexArrow(0, 158);
 SetIndexArrow(1, 158);
 SetIndexArrow(2, 159);
 SetIndexArrow(3, 159);
 SetIndexArrow(4, 159);
 SetIndexArrow(5, 159);
   
   SetIndexLabel(0,"Resistance_1");
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,1,Red);
   SetIndexDrawBegin(0,i-1);
   SetIndexBuffer(0, mabel01);
   SetIndexLabel(1,"Support_1");
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1,Blue);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, mabel02);
   
   SetIndexLabel(2,"Resistance_2");   
   SetIndexStyle(2,DRAW_ARROW,STYLE_DOT,2,Red);
   SetIndexDrawBegin(2,i-1);
   SetIndexBuffer(2, mabel11);
   SetIndexLabel(3,"Support_2");
   SetIndexStyle(3,DRAW_ARROW,STYLE_DOT,2,Blue);
   SetIndexDrawBegin(3,i-1);
   SetIndexBuffer(3, mabel12);
   
   SetIndexLabel(4,"Resistance_3");   
   SetIndexStyle(4,DRAW_ARROW,STYLE_DOT,4,Red);
   SetIndexDrawBegin(4,i-1);
   SetIndexBuffer(4, mabel21);
   SetIndexLabel(5,"Support_3");
   SetIndexStyle(5,DRAW_ARROW,STYLE_DOT,4,Blue);
   SetIndexDrawBegin(5,i-1);
   SetIndexBuffer(5, mabel22);
   
  if( autoset)
  { 
   auto=" TRUE";
    if(Period()==1)
   {TimeFrame1=5;TimeFrame2=15;TimeFrame3=30;}     //1, 5, 30
   else if(Period()==5)
   {TimeFrame1=1;TimeFrame2=5;TimeFrame3=30;}
   
   else if(Period()==15)
   {TimeFrame1=5;TimeFrame2=15;TimeFrame3=60;}
   
   else if(Period()==30)
   {TimeFrame1=5;TimeFrame2=30;TimeFrame3=240;}
   
   else if(Period()==60)
   {TimeFrame1=15;TimeFrame2=60;TimeFrame3=240;}
   
   else if(Period()==240)
   {TimeFrame1=60;TimeFrame2=240;TimeFrame3=1440;}
   
   else if(Period()==1440)
   {TimeFrame1=240;TimeFrame2=1440;TimeFrame3=10080;}
   else if(Period()==10080)
   {TimeFrame1=1440;TimeFrame2=10080;TimeFrame3=43200;}
  } 
   per[0]=TimeFrame1;
   per[1]=TimeFrame2;
   per[2]=TimeFrame3;
   
   first=true;
   return(0);
  }
  
int deinit()
   {
      Comment(" ");
      for( int  i =0; i<=70000;i++)
      {
       ObjectDelete("hor"+i);
      } 
      
   return(0);
   }
int start()
  {
    RefreshRates();
   int Counted_bars=IndicatorCounted();
   if(first)
      int newbars =Bars-Counted_bars-1;
   else newbars =40;
   for(int a=0;a<=3;a++)    // M1 ,M5, M15, M30 ,H1   get all data values
      {
        for( i=newbars;i>=0; i--)          // back shifts to use
         {
            datetime time = iTime(NULL,Period(),i);
        int h=i;
            shift[a]=iBarShift(NULL,per[a],time,true);
            mabel1 = iFractals(NULL, per[a], MODE_UPPER,shift[a]);
            mabel2 = iFractals(NULL, per[a], MODE_LOWER,shift[a]);
            double low=iLow(NULL,per[a],shift[a]);
            double high=iHigh(NULL,per[a],shift[a]);
            double open=iOpen(NULL,per[a],shift[a]);
      
  
         switch(a)
         {
          case 0:
                 if (mabel1 > 0) 
                   mabel01[i]=high;
                else
                   mabel01[i] = mabel01[i+1]; 
                   
                 if (mabel2 > 0) 
                   mabel02[i]=low;
                else
                   mabel02[i] = mabel02[i+1];

               high0=mabel01[i];
               low0=mabel02[i];   
              break;
       
          case 1:
                 if (mabel1 > 0) 
                   mabel11[i]=high;
                else
                   mabel11[i] = mabel11[i+1]; 
                 if (mabel2 > 0) 
                   mabel12[i]=low;
                else
                   mabel12[i] = mabel12[i+1];
               high1=mabel11[i];
               low1=mabel12[i];
              break;
       
          case 2:
                 if (mabel1 > 0) 
                   mabel21[i]=high;
                else
                   mabel21[i] = mabel21[i+1]; 
                 if (mabel2 > 0) 
                   mabel22[i]=low;
                else
                   mabel22[i] = mabel22[i+1];
                 high2=mabel21[i];
               low2=mabel22[i];
              break;
        case 3:
 if(showinfo)        Comment(" \n\n\n\n MultiTimeFrame Resistance and Support\n\n AUTHOR : Olowoyo Olufikayo \n\n CREATED :18/05/2009.... LAST UPDATED: 17/08/2009 \n\n AUTOSET TIMEFRAME IS SET TO",auto,"\n LOW TIMEFRAME= ",TimeFrame1,"\n OWN TIMEFRAME= ",TimeFrame2,"\n HIGH TIMEFRAME= ",TimeFrame3,
      "\n\n Last High on ",TimeFrame1," is ",high0,".....Last Low is ",low0,
      "\n Last High on ",TimeFrame2," is ",high1,".....Last Low is ",low1,
      "\n Last High on ",TimeFrame3," is ",high2,".....Last Low is ",low2,
      "\n\n Buying Price is ; ",Ask,"...........Selling Price is : ",Bid);
         break;
        }// end  of switch///////////////
       }
    }  
   
    for( i=newbars;i>=0; i--)          // back shifts to use
     if(showlines&& mabel01[i]==mabel11[i] && mabel11[i]== mabel21[i] && mabel02[i]==mabel12[i] && mabel12[i]== mabel22[i] && last=="sell") 
        {
       h++;
       ObjectCreate("hor"+h,OBJ_VLINE,0,0,0);
           ObjectSet("hor"+h, OBJPROP_TIME1, Time[i]);  
           ObjectSet("hor"+h, OBJPROP_COLOR, Aqua);
           ObjectSet("hor"+h, OBJPROP_STYLE, 3);
           ObjectSet("hor"+h, OBJPROP_WIDTH, 2);
           last="buy";
       } 
    else if(showlines&&mabel01[i]==mabel11[i] && mabel11[i]== mabel21[i] && mabel02[i]==mabel12[i] && mabel12[i]== mabel22[i] && last=="buy") 
        {
       h++;
       ObjectCreate("hor"+h,OBJ_VLINE,0,0,0);
           ObjectSet("hor"+h, OBJPROP_TIME1, Time[i]);  
           ObjectSet("hor"+h, OBJPROP_COLOR, Red);
           ObjectSet("hor"+h, OBJPROP_STYLE, 3);
           ObjectSet("hor"+h, OBJPROP_WIDTH, 2);
           last="sell";
       } 
        
  else if(showlines&& mabel01[i]==mabel11[i] && mabel11[i]== mabel21[i]) 
      {
       h++;
       ObjectCreate("hor"+h,OBJ_VLINE,0,0,0);
           ObjectSet("hor"+h, OBJPROP_TIME1, Time[i]);  
           ObjectSet("hor"+h, OBJPROP_COLOR, Red);
           ObjectSet("hor"+h, OBJPROP_STYLE, 3);
           ObjectSet("hor"+h, OBJPROP_WIDTH, 2);
           last="sell";
      }
   else  if(showlines&&mabel02[i]==mabel12[i] && mabel12[i]== mabel22[i]) 
      {
       h++;
       ObjectCreate("hor"+h,OBJ_VLINE,0,0,0);
           ObjectSet("hor"+h, OBJPROP_TIME1, Time[i]);  
           ObjectSet("hor"+h, OBJPROP_COLOR, Aqua);
           ObjectSet("hor"+h, OBJPROP_STYLE, 3);
           ObjectSet("hor"+h, OBJPROP_WIDTH, 2);
           last="buy";
      }
   else last="exit";
   return(0);
  }
 
//+------------------------------------------------------------------+

Comments