Grid_Builder

Download script
Author: Copyright � 2005, Siddiqi, Alejandro Galindo
Grid_Builder

This tool is designed to automatically generate a visual pricing grid on your trading chart. Its primary purpose is to provide traders with a clear, organized layout of horizontal price levels, helping to better visualize market structure and key price points.

How the Logic Works

1. Dynamic Range Identification Instead of using a fixed set of numbers, the script automatically analyzes recent market activity to determine where to place the grid. It looks at the highest and lowest prices reached over a specific period of time. By identifying these boundaries, the tool ensures that the grid remains relevant to the current price action on your screen.

2. Precise Grid Spacing The logic includes a calculation system that translates raw price data into standardized intervals. It uses a "Grid Space" setting, which determines how frequently the lines appear. The script calculates these positions mathematically to ensure that the lines are evenly distributed and consistent across the entire visible range of the chart.

3. Automated Drawing and Cleanup The tool handles the heavy lifting of drawing the lines for you:

  • Automatic Creation: It continuously scans the price range between the identified high and low points. If a required grid line is missing, the script automatically draws it as a solid horizontal line.
  • Visual Consistency: Every line is assigned a specific style (solid) and color (Medium Sea Green) to maintain a professional and clean look on your workspace.
  • Self-Maintenance: To keep your chart from becoming cluttered with old data, the script includes a cleanup routine. When the market moves significantly, it identifies and removes lines that are no longer within the active trading range, ensuring that only the most relevant grid remains visible.

Summary for Traders

Essentially, this script acts as an automated drafting tool. It monitors where the price is moving, calculates the most logical intervals for your analysis, and paints a clean, consistent grid on your chart automatically, allowing you to focus on your trading strategy rather than manual drawing.

11 Views
0 Downloads
0 Favorites
Grid_Builder
//+------------------------------------------------------------------+
//|                                      2Extreme4U Grid Builder.mq4 |
//|                     Copyright © 2005, Siddiqi, Alejandro Galindo |
//|                                              http://elCactus.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Siddiqi, Alejandro Galindo"
#property link      "http://elCactus.com"

#property indicator_chart_window
extern int GridSpace=50;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   double shift=0;
   double HighPrice=0;
   double LowPrice=0;

   double Divisor=0.1/Point;

   HighPrice=MathRound(High[Highest(NULL,0,2, Bars - 2,  2)] * Divisor);
   //SL = High[Highest(MODE_HIGH, SLLookback, SLLookback)];
   LowPrice=MathRound(Low[Lowest(NULL,0,1, Bars - 1, 2)] * Divisor);
   for(shift=LowPrice;shift<=HighPrice;shift++)
     {
      ObjectDelete("Grid"+shift);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   double I=0;
   double HighPrice=0;
   double LowPrice=0;
   int GridS=0;
   int SL=0;
//----    

   double Divisor=0.1/Point;

   HighPrice=MathRound(High[Highest(NULL,0,MODE_HIGH, Bars - 2, 2)] * Divisor);
   //SL = High[Highest(MODE_HIGH, SLLookback, SLLookback)];
   LowPrice=MathRound(Low[Lowest(NULL,0,MODE_LOW, Bars - 1, 2)] * Divisor);
   GridS=GridSpace/10;

   for(I=LowPrice;I<=HighPrice;I++)
     {
      //Print("mod(I, GridSpace): " + MathMod(I, GridS) + " I= " + I);
      //Print(LowPrice + " " + HighPrice);
      if (MathMod(I, GridS)==0)
        {
         if (ObjectFind("Grid"+I)!=0)
           {
            ObjectCreate("Grid"+I, OBJ_HLINE, 0, Time[1], I/Divisor);
            ObjectSet("Grid"+I, OBJPROP_STYLE, STYLE_SOLID);
            ObjectSet("Grid"+I, OBJPROP_COLOR, MediumSeaGreen);
           }
         //MoveObject(I + "Grid", OBJ_HLINE, Time[Bars - 2], I/1000, Time[1], I/1000, MediumSeaGreen, 1, STYLE_SOLID);
        }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments