Author: Copyright � 2006
All S&R

This script is a visual trading tool designed for the MetaTrader platform to help traders identify key Support and Resistance levels across different timeframes simultaneously. By automating the identification of these price points, it provides a clear snapshot of market structure at a glance.

Core Functionality

The tool automatically scans three distinct timeframes—Monthly (MN1), Weekly (W1), and Daily (D1)—to extract the highest and lowest prices reached during the previous completed period. It then plots these values directly on your current chart as horizontal lines.

Visual Components

To keep the chart organized and readable, the script categorizes the information into three distinct groups:

  • Resistance Levels (Highs): These represent potential "ceilings" where price may face selling pressure. The tool identifies the high of the previous month, week, and day.
  • Support Levels (Lows): These represent potential "floors" where price may find buying interest. The tool identifies the low of the previous month, week, and day.
  • Dynamic Labels: In addition to drawing the lines, the script generates a text dashboard on your screen. This dashboard provides:
    • The exact numerical price for every identified level.
    • The "Range" calculation (the distance between the Support and Resistance for each specific timeframe), displayed in pips.

Technical Behavior

  • Color Coding: The script uses specific colors (Yellow, Spring Green, and Tan) to differentiate between Monthly, Weekly, and Daily data, ensuring you can quickly distinguish between different time horizons.
  • Automatic Updates: The tool constantly recalculates based on the most recent completed candles, ensuring your chart stays updated as new trading sessions begin.
  • Clean Environment: The script includes a built-in "cleanup" feature that automatically removes its visual objects from the chart when you close or remove the indicator, leaving no leftover clutter behind.

In summary, this tool simplifies market analysis by consolidating significant historical price data into a single, easy-to-read visual layout, allowing you to see where the major "boundaries" of the market lie across multiple timeframes at once.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
12 Views
0 Downloads
0 Favorites
All S&R
//+------------------------------------------------------------------+
//|                                                      3 S & R.mq4 |
//|                                                 Copyright © 2006 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006"
#property link      ""

#property indicator_chart_window

//---- input parameters
extern int DD=4;//--- decimal places
//---- buffers



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
//---- indicators
   
   
   
   
//---- Objects

double    R1,R2,R3,S1,S2,S3;
   R1 = iHigh(NULL,PERIOD_MN1,1);
   R2 = iHigh(NULL,PERIOD_W1,1);
   R3 = iHigh(NULL,PERIOD_D1,1);
   S1 = iLow(NULL,PERIOD_MN1,1);
   S2 = iLow(NULL,PERIOD_W1,1);
   S3 = iLow(NULL,PERIOD_D1,1); 

   
   ObjectCreate("MR",OBJ_HLINE,0,0,R1);
   ObjectSet("MR",OBJPROP_COLOR,Yellow);
   ObjectSet("MR",OBJPROP_STYLE,STYLE_SOLID);
   
   ObjectCreate("WR",OBJ_HLINE,0,0,R2);
   ObjectSet("WR",OBJPROP_COLOR,SpringGreen);
   ObjectSet("WR",OBJPROP_STYLE,STYLE_SOLID);
   
   ObjectCreate("DR",OBJ_HLINE,0,0,R3);
   ObjectSet("DR",OBJPROP_COLOR,Tan);
   ObjectSet("DR",OBJPROP_STYLE,STYLE_SOLID);
   
   ObjectCreate("MS",OBJ_HLINE,0,0,S1);
   ObjectSet("MS",OBJPROP_COLOR,Yellow);
   ObjectSet("MS",OBJPROP_STYLE,STYLE_SOLID);
   
   ObjectCreate("WS",OBJ_HLINE,0,0,S2);
   ObjectSet("WS",OBJPROP_COLOR,SpringGreen);
   ObjectSet("WS",OBJPROP_STYLE,STYLE_SOLID);
   
   ObjectCreate("DS",OBJ_HLINE,0,0,S3);
   ObjectSet("DS",OBJPROP_COLOR,Tan);
   ObjectSet("DS",OBJPROP_STYLE,STYLE_SOLID);
   
   
  
   ObjectsRedraw();
   
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
  double    R1,R2,R3,S1,S2,S3,rg1,rg2,rg3,fx,bcl,bch,bc,sch,scl,sc;
  int rg1a,rg2a,rg3a;
 
   if(DD==2)
   {
   fx=100;
   }
   else
   {
   fx=10000;
   }  
   
   
   R1 = iHigh(NULL,PERIOD_MN1,1);
   R2 = iHigh(NULL,PERIOD_W1,1);
   R3 = iHigh(NULL,PERIOD_D1,1);
   S1 = iLow(NULL,PERIOD_MN1,1);
   S2 = iLow(NULL,PERIOD_W1,1);
   S3 = iLow(NULL,PERIOD_D1,1);
   rg1=(R1-S1)*fx;
   rg2=(R2-S2)*fx;
   rg3=(R3-S3)*fx;
   rg1a=MathRound(rg1);
   rg2a=MathRound(rg2);
   rg3a=MathRound(rg3);
   string R1a=DoubleToStr(R1,DD);
   string R2a=DoubleToStr(R2,DD);
   string R3a=DoubleToStr(R3,DD);
   string S1a=DoubleToStr(S1,DD);
   string S2a=DoubleToStr(S2,DD);
   string S3a=DoubleToStr(S3,DD);
   
   
   
   drawLabel("RL","MR:   "+R1a+"       WR:  "+R2a+"      DR:  "+R3a,12,SkyBlue,5,35,"Arial Narrow");
   drawLabel("SRR","MRg: "+rg1a+" pips    WRg: "+rg2a+" pips    DRg: "+rg3a+" pips",10,SpringGreen,5,20,"Arial Narrow");
   drawLabel("SL","MS:   "+S1a+"       WS:  "+S2a+"      DS:  "+S3a,12,Tan,5,5,"Arial Narrow");
   
   ObjectsRedraw();
 
 //---- 
   return(0);
  }
//+------------------------------------------------------------------+

void drawLabel(string id, string text,int fsize, color fcolor,int x,int y,string font="Arial Narrow",int window = 0)

     { if(ObjectFind(id)==-1)
         {
         ObjectCreate(id, OBJ_LABEL, window, 0, 0);
        ObjectSetText(id,text, fsize, font, fcolor);
        ObjectSet(id, OBJPROP_CORNER, 2);
        ObjectSet(id, OBJPROP_XDISTANCE, x);
        ObjectSet(id, OBJPROP_YDISTANCE, y);
        }
        
     
  }

Comments