Support_and_Resistance_FOREX

Download script
Author: Copyright � 2006, Jason Robinson (jnrtrading)
Support_and_Resistance_FOREX

This script is designed to automate the identification and visualization of key price levels—specifically Support and Resistance—on a trading chart. By analyzing historical price data, it helps traders see where significant price action occurred in the past, allowing for better anticipation of future market movements.

Core Functionality

The primary purpose of this tool is to scan a specific number of previous days (which can be customized by the user) and plot horizontal markers based on the highest and lowest prices reached during those periods. These levels act as visual cues: "Support" marks where price had a hard time falling further, and "Resistance" marks where price had a hard time rising further.

How the Logic Works

The script processes data in three distinct ways to organize the chart clearly:

1. Historical Benchmarking The tool looks back at the daily candles for the duration set by the user. For each day in this period, it identifies the highest and lowest price points. It then draws dashed lines on the chart to represent these peaks and valleys. These lines stay in their respective historical positions, providing a "map" of past volatility.

2. Real-Time Today's Levels The script includes specific logic to monitor the current day's activity. It compares today’s high and low prices against the previous day's data. If today's price has surpassed the previous day's highs or lows, it dynamically draws specific lines for the current day. This ensures that traders can see the immediate boundaries of the current trading session.

3. Projected Support and Resistance Beyond just showing where prices were, the script projects specific levels forward. It takes the high and low data points from previous days and extends them onto the current price action area as dotted lines. This allows a trader to see how old "walls" of resistance or "floors" of support might still influence the price as it moves through the current day.

Visual Organization

To keep the chart readable, the script uses a coordinated color system:

  • Highs/Resistance: Typically highlighted in Red (or a user-defined color) to signify upper limits.
  • Lows/Support: Typically highlighted in Blue (or a user-defined color) to signify lower limits.
  • Style Differentiation: The script uses different line styles (such as dashes and dots) to distinguish between historical levels, current day levels, and projected boundaries, ensuring the chart remains organized and easy to interpret at a glance.

Summary for the Trader

Instead of manually scanning weeks of data to find where the market "stalled" in the past, this script does the heavy lifting automatically. It paints a visual history of price limits directly on your screen, highlighting both the boundaries of the current day and the significant milestones from recent history.

14 Views
1 Downloads
0 Favorites
Support_and_Resistance_FOREX
//+-------------------------------------------------------+\\
//| Support_and_Resistance_FOREX.mq4 Release 20061106-rc1 |\\
//|     Copyright © 2006, jnrtrading (Jason Robinson)     |\\
//|    Contact @ http://www.spreadtrade2win.com/forum/    |\\
//+-------------------------------------------------------+\\
#property copyright "Copyright © 2006, Jason Robinson (jnrtrading)"
#property link      "http://www.spreadtrade2win.com/forum/"

#property indicator_chart_window
extern int How_Many_Days_To_Calculate = 10;
extern color High_Line_Colour = Red;
extern color Low_Line_Colour = Blue;
extern color Todays_High_Line_Colour = Red;
extern color Todays_Low_Line_Colour = Blue;
extern color SR_Line_Colour = Black;
int x;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
//---- indicators
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {
//----
   for (x = 0; x <=How_Many_Days_To_Calculate; x++) {
      ObjectDelete("HighLine"+x);
      ObjectDelete("LowLine"+x);
      ObjectDelete("SRa"+x);
      ObjectDelete("SRb"+x);
   }
   ObjectDelete("TodaysHighLine");
   ObjectDelete("TodaysLowLine");
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   double Rates[][6];
   int i = 0;
   static datetime prevtime = 0;
   ArrayCopyRates(Rates,Symbol(),PERIOD_D1);
//----
   
   
   for (i=1; i<How_Many_Days_To_Calculate; i++) {
      ObjectDelete("HighLine"+i);
      ObjectCreate("HighLine"+i,OBJ_TREND,0, iTime(NULL,PERIOD_D1,i), Rates[i][3], iTime(NULL,PERIOD_D1,i-1)+86400, Rates[i][3]);
      ObjectSet("HighLine"+i, OBJPROP_RAY, false);
      ObjectSet("HighLine"+i, OBJPROP_BACK, true);
      ObjectSet("HighLine"+i, OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("HighLine"+i, OBJPROP_COLOR, High_Line_Colour);
      
      ObjectDelete("LowLine"+i);
      ObjectCreate("LowLine"+i,OBJ_TREND,0, iTime(NULL,PERIOD_D1,i), Rates[i][2], iTime(NULL,PERIOD_D1,i-1)+86400, Rates[i][2]);
      ObjectSet("LowLine"+i, OBJPROP_RAY, false);
      ObjectSet("LowLine"+i, OBJPROP_BACK, true);
      ObjectSet("LowLine"+i, OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("LowLine"+i, OBJPROP_COLOR, Low_Line_Colour);
   }
   if (Rates[0][3] > Rates[1][3]) {
      ObjectDelete("TodaysHighLine");
      ObjectCreate("TodaysHighLine",OBJ_TREND,0, iTime(NULL,PERIOD_D1,0), Rates[0][3], iTime(NULL,PERIOD_D1,0)+86400, Rates[0][3]);
      ObjectSet("TodaysHighLine", OBJPROP_RAY, false);
      ObjectSet("TodaysHighLine", OBJPROP_BACK, true);
      ObjectSet("TodaysHighLine", OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("TodaysHighLine", OBJPROP_COLOR, Todays_High_Line_Colour);      
   }
   if (Rates[0][2] < Rates[1][2]) {
      ObjectDelete("TodaysLowLine");
      ObjectCreate("TodaysLowLine",OBJ_TREND,0, iTime(NULL,PERIOD_D1,0), Rates[0][2], iTime(NULL,PERIOD_D1,0)+86400, Rates[0][2]);
      ObjectSet("TodaysLowLine", OBJPROP_RAY, false);
      ObjectSet("TodaysLowLine", OBJPROP_BACK, true);
      ObjectSet("TodaysLowLine", OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("TodaysLowLine", OBJPROP_COLOR, Todays_Low_Line_Colour);      
   }
   for (i=2; i<=How_Many_Days_To_Calculate; i++) {
      ObjectDelete("SRa"+(i-2));
      ObjectCreate("SRa"+(i-2),OBJ_TREND,0, iTime(NULL,PERIOD_D1,1), Rates[i][3], iTime(NULL,PERIOD_D1,0)+86400, Rates[i][3]);
      ObjectSet("SRa"+(i-2), OBJPROP_RAY, false);
      ObjectSet("SRa"+(i-2), OBJPROP_BACK, true);
      ObjectSet("SRa"+(i-2), OBJPROP_STYLE, STYLE_DOT);
      ObjectSet("SRa"+(i-2), OBJPROP_COLOR, SR_Line_Colour);

      ObjectDelete("SRb"+(i-2));
      ObjectCreate("SRb"+(i-2),OBJ_TREND,0, iTime(NULL,PERIOD_D1,1), Rates[i][2], iTime(NULL,PERIOD_D1,0)+86400, Rates[i][2]);
      ObjectSet("SRb"+(i-2), OBJPROP_RAY, false);
      ObjectSet("SRb"+(i-2), OBJPROP_BACK, true);
      ObjectSet("SRb"+(i-2), OBJPROP_STYLE, STYLE_DOT);
      ObjectSet("SRb"+(i-2), OBJPROP_COLOR, SR_Line_Colour);
   }
   ObjectsRedraw();
//----
   return(0);
}
//+------------------------------------------------------------------+

Comments