Author: Copyright � 2006, Eli hayun
Fib_SR

This technical tool is designed to automatically identify and visualize key price levels on your trading chart based on the previous day's market activity. Rather than requiring you to manually calculate complex mathematical formulas, the script handles all the geometry behind the scenes to highlight potential areas of support and resistance.

How the Logic Works

The core logic of this tool relies on analyzing the "Daily" timeframe. Every time a new trading day begins, the script performs a series of automated calculations based on three primary data points from the previous day:

  • The High: The highest price reached.
  • The Low: The lowest price reached.
  • The Close: The final price at which the market ended.

Automated Calculations

Using these three points, the tool calculates a "Range" (the distance between the high and low) and identifies a central average price. From this center point, it derives several specific zones:

  1. Support Zones: The script identifies two distinct areas below the current price action where buyers might step in to prevent further downward movement. These are represented as visual boxes on your chart.
  2. Resistance Zones: Conversely, the tool identifies two distinct areas above the current price action where sellers might become active, potentially capping upward movement.

Visual Representation

Instead of just providing you with numbers in a list, the script draws actual shapes directly on your trading screen:

  • Dynamic Updating: The levels automatically refresh at the start of every new day, ensuring your chart always reflects the most recent market data.
  • Color Coding: To make the chart easy to read at a glance, the tool uses different colors for each zone (such as DeepSkyBlue and Coral), allowing you to quickly distinguish between "buying" support areas and "selling" resistance areas.

Summary of User Experience

Essentially, this tool acts as an automated analyst. It looks at what happened yesterday, calculates where the market's mathematical balance lies today, and paints those boundaries on your screen so you can see potential "floors" and "ceilings" in real-time without doing any manual math.

Price Data Components
Series array that contains close prices for each barSeries array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
7 Views
0 Downloads
0 Favorites
Fib_SR
//+------------------------------------------------------------------+
//|                                                       Fib SR.mq4 |
//|                                      Copyright © 2006, Eli hayun |
//|                                          http://www.elihayun.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"
#property link      "http://www.elihayun.com"
//----
#property indicator_chart_window
//----
#define FIB_SUP1 "FIB_SUP_1"
#define FIB_SUP2 "FIB_SUP_2"
#define FIB_RES1 "FIB_RES_1"
#define FIB_RES2 "FIB_RES_2"
//----
extern color clrSup1=DeepSkyBlue;
extern color clrSup2=Aqua;
extern color clrRes1=Coral;
extern color clrRes2=Tan;
//----
double A, B, C, D, E;
double A1, B1, D1, E1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   Recalc();
   ObjectDelete(FIB_SUP1);
   ObjectDelete(FIB_SUP2);
   ObjectDelete(FIB_RES1);
   ObjectDelete(FIB_RES2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   static datetime dt=0;
   if (dt!=iTime(NULL, PERIOD_D1,0))
     {
      Recalc();
      dt=iTime(NULL, PERIOD_D1,0);
     }
   if (NewBar())
     {
      ObjectDelete(FIB_SUP1);
      ObjectDelete(FIB_SUP2);
      ObjectDelete(FIB_RES1);
      ObjectDelete(FIB_RES2);
      //
      ObjectCreate(FIB_SUP1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), B, Time[0], B1);  ObjectSet(FIB_SUP1, OBJPROP_COLOR, clrSup1);
      ObjectCreate(FIB_SUP2, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), A, Time[0], A1);  ObjectSet(FIB_SUP2, OBJPROP_COLOR, clrSup2);
      ObjectCreate(FIB_RES1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), D, Time[0], D1);  ObjectSet(FIB_RES1, OBJPROP_COLOR, clrRes1);
      ObjectCreate(FIB_RES2, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), E, Time[0], E1);  ObjectSet(FIB_RES2, OBJPROP_COLOR, clrRes2);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
bool NewBar()
  {
   static datetime dt=0;
   if (dt!=Time[0])
     {
      dt=Time[0];
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Recalc()
  {
   double C=iClose(NULL, PERIOD_D1, 1); // Yesterday close
   double L=iLow(NULL, PERIOD_D1, 1); // Yesterday Low
   double H=iHigh(NULL, PERIOD_D1, 1); // Yesterday High
   double R=(H-L);
//----
   C=(H+L+C)/3;
   D=(R/2) + C;
   B=C - (R/2);
   E=R + C;
   A=C - R;
//----
   B1=C -(R * 0.618 );
   A1=C -(R * 1.382 );
//----
   D1=C +(R * 0.618 );
   E1=C +(R * 1.382 );
  }
//+------------------------------------------------------------------+

Comments