MP Overlay_v1

Download script
Author: Copyright � 2005, Sfen
MP Overlay_v1

This tool functions as a visual diagnostic aid designed to identify "price friction" or zones of high activity within a specific period of market history. Instead of just showing where the price ended up, it maps out the entire path the price traveled to reveal which areas were touched most frequently.

How the Logic Works

1. Historical Data Analysis The script begins by scanning a defined amount of historical price action (which can be adjusted by the user). During this scan, it identifies two critical boundaries: the absolute highest point reached and the absolute lowest point reached within that timeframe.

2. Grid Mapping Once the high and low boundaries are established, the tool creates a virtual grid between them. Think of this as dividing the vertical space of the chart into tiny, equal increments. Each increment represents a specific price level.

3. Density Calculation (The "Sensor" Logic) This is the core of the script. The logic iterates through every single past candle and looks at the range between its opening and closing prices. For every unit of price that a candle covered, the script "marks" that spot on the grid.

  • If many different candles overlap at the same price level, that specific point receives a higher count.
  • If only a few candles pass through a price level, it receives a lower count.

4. Visual Representation Finally, the script translates these counts into visual trend lines on your chart. Each line represents a unique price level. The horizontal length of each line is determined by how many times that specific price point was "hit" or occupied by historical candles.

Key Takeaways for the User

  • Identifying Support and Resistance: Areas where the lines are significantly longer indicate "high-traffic" zones—prices where the market spent a lot of time struggling or consolidating.
  • Visualizing Volatility: By looking at the distribution of these lines, you can see where price action was dense versus where it moved quickly through "empty" space.
  • Dynamic Updates: The tool automatically clears old markers and redraws the entire map every time the chart refreshes, ensuring your visual data always matches the most recent historical window.
12 Views
0 Downloads
0 Favorites
MP Overlay_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                 Level Sensor.mq4 |
//|                                          Copyright © 2005, Sfen. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Sfen"
#property indicator_chart_window
//---- input parameters
extern int       MAX_HISTORY=500;
extern int       STEP = 1;
int init()
  {
   return(0);
  }
double CSH(int shift)
{
 return (MathMax(Open[shift],Close[shift]));
}
double CSL(int shift)
{
 return (MathMin(Open[shift],Close[shift]));
}
string OBJECT_PREFIX = "LEVELS";
int ObjectId = 0;
string IntToStr(int X)
{
 return (DoubleToStr(X,0));
}
string ObGetUniqueName(string Prefix)
{
 ObjectId++;
 return (Prefix+" "+IntToStr(ObjectId));
}
void   ObDeleteObjectsByPrefix(string Prefix)
{
 int L = StringLen(Prefix);
 int i=0; 
 while (i<ObjectsTotal())
 {
  string ObjName = ObjectName(i);
  if (StringSubstr(ObjName,0,L)!=Prefix) { i++; continue;}
  ObjectDelete(ObjName);
 }
}
int deinit()
  {
   ObDeleteObjectsByPrefix(OBJECT_PREFIX);
   return(0);
  }
int start()
  {
   string S;
   ObDeleteObjectsByPrefix(OBJECT_PREFIX);
   double HH = 0;
   double LL = 1000000;
   int History = MathMin(Bars,MAX_HISTORY);
   
   int i, j, k;
   for (i=1; i<History; i++)
   {
    HH = MathMax(HH,CSH(i));
    LL = MathMin(LL,CSL(i));
   }
   int NumberOfPoints = (HH-LL)/(1.0*Point*STEP)+1;
   int Count[];
   ArrayResize(Count,NumberOfPoints);
   
   for (i=0; i<NumberOfPoints; i++) Count[i]=0;
   for (i=1; i<History; i++)
   {
    double C = CSL(i);
    while (C<CSH(i))
    {
     int Index = (C-LL)/(1.0*Point*STEP);
     Count[Index]++;    
     C += 1.0*Point*STEP;
    }
   }
   
   for (i=0; i<NumberOfPoints; i++)
   {
    double StartX = Time[5];
    double StartY = LL + 1.0*Point*STEP*i;
    double EndX   = Time[5+Count[i]];
    double EndY   = StartY;
      
    string ObjName = ObGetUniqueName(OBJECT_PREFIX);
    ObjectDelete(ObjName);
    ObjectCreate(ObjName,OBJ_TREND,0,StartX,StartY,EndX,EndY);
    ObjectSet(ObjName,OBJPROP_RAY,0);
    ObjectSet(ObjName,OBJPROP_COLOR,Red);
    
   }
   return(0);
  }
//+------------------------------------------------------------------+


Comments