s-gorizontali
Download scriptThis tool is designed to assist traders by automatically generating a balanced grid of horizontal price levels on a trading chart. Instead of manually drawing dozens of lines to identify potential support and resistance zones, this script allows you to create a structured visual map based on a single price point of your choosing.
Core Functionality
The primary logic of the script is centered on symmetrical expansion. When you interact with the chart to select a specific price, the tool takes that "anchor" price and projects a series of lines both above and below it. It calculates these positions based on a set distance (step) that you can define, ensuring that the grid remains organized and mathematically consistent.
Key Features & Logic
- Symmetrical Distribution: For every line created above your chosen price, the script automatically generates a corresponding line below it. This provides a holistic view of the market's surrounding price territory.
- Customizable Density: You can control how many lines appear in each direction (Quantity). This allows you to choose between a dense "web" of price levels or a few widely spaced markers depending on your trading style.
- Dynamic Spacing: The script includes logic to adjust the distance between lines. It supports both standard spacing and an optional "acceleration" factor, which can cause the distance between the lines to widen as they move further away from the center point.
- Visual Customization: To ensure the grid is easy to read at a glance, the tool distinguishes between different sections of the grid using distinct colors (such as red for the primary level and shades of blue for the extended levels). You can also customize the thickness and style (solid, dashed, etc.) of these lines.
- Automated Cleanup: The script includes a "Full Delete" feature. When you remove the tool from your chart, it has the capability to automatically clear all the generated lines, leaving your workspace clean without requiring you to delete each line individually.
How it Benefits the User
This script transforms the manual task of charting into an automated process. By providing a visually organized "horizon" of price levels, it helps traders identify where significant price action might occur, making it easier to spot potential areas of interest while maintaining a clean and professional chart layout.
//+------------------------------------------------------------------+
//| gorizontali.mq4 |
//| bor-ix |
//+------------------------------------------------------------------+
#property copyright "bor-ix"
#property show_inputs
string LineName = "ãîðèçîíòàëü";
extern int LineKoli4 = 10;
extern int LineShag = 100;
extern int PriroShenie = 0;
color LineColor, LineColor01, LineColor02;
extern color LineColor0 = Red;
extern color LineColor1 = DodgerBlue;
extern color LineColor2 = DarkSlateBlue;
extern int LineStyle = 0;
extern int LineWidth = 2;
extern bool DELETE.FULL = false;
int i, ii;
double gorizontal;
int deinit()
{
if (DELETE.FULL == true)
{
for (ii=0;ii<LineKoli4*1000;ii++)
{
ObjectDelete(LineName+"+"+DoubleToStr(ii,0));
ObjectDelete(LineName+"-"+DoubleToStr(ii,0));
}
return(0);
}
}
int start()
{
int digits = MarketInfo(Symbol(),MODE_DIGITS);
double value = WindowPriceOnDropped();
for(int i=0; i<LineKoli4; i++)
{
ii++;
if (i == 0) {LineColor01 = LineColor0; LineColor02 = LineColor0;}
else {LineColor01 = LineColor1; LineColor02 = LineColor2;}
gorizontal=value+i*(LineShag+(PriroShenie*i-PriroShenie)/2)*Point;
{
ObjectDelete (LineName+"+"+DoubleToStr(ii,0));
ObjectCreate (LineName+"+"+DoubleToStr(ii,0),OBJ_HLINE,0,0,gorizontal);
ObjectSet (LineName+"+"+DoubleToStr(ii,0),OBJPROP_STYLE,LineStyle);
ObjectSet (LineName+"+"+DoubleToStr(ii,0),OBJPROP_COLOR,LineColor01);
ObjectSet (LineName+"+"+DoubleToStr(ii,0),OBJPROP_WIDTH,LineWidth);
}
gorizontal=value-i*(LineShag+(PriroShenie*i-PriroShenie)/2)*Point;
{
ObjectDelete (LineName+"-"+DoubleToStr(ii,0));
ObjectCreate (LineName+"-"+DoubleToStr(ii,0),OBJ_HLINE,0,0,gorizontal);
ObjectSet (LineName+"-"+DoubleToStr(ii,0),OBJPROP_STYLE,LineStyle);
ObjectSet (LineName+"-"+DoubleToStr(ii,0),OBJPROP_COLOR,LineColor02);
ObjectSet (LineName+"-"+DoubleToStr(ii,0),OBJPROP_WIDTH,LineWidth);
}
}
return(0);
}
Comments