DrawLine
Download scriptThis tool is designed to simplify the visual organization of your trading charts by allowing you to place multiple horizontal reference lines at specific price levels. Instead of manually drawing lines every time you want to mark a significant area, this script automates the process based on user-defined settings.
Core Functionality
The script provides eight independent slots where you can define specific price points. For each slot, the tool allows you to customize three key visual elements:
- Price Level: You can input the exact numerical value where you want a horizontal line to appear. If a value is left at zero, the script ignores that slot, allowing you to use as many or as few lines as needed (up to eight).
- Color: Each line can be assigned a unique color to help differentiate between different types of data—for example, using different colors for support levels, resistance zones, or profit targets.
- Thickness: You can adjust the visual weight (width) of each line, making it easier to highlight major price boundaries while keeping secondary markers more subtle.
How It Works on Your Chart
Once the script is active, it scans the settings you have provided. For every price value entered that is not empty, the tool automatically generates a "Horizontal Line" object. These lines span across the entire width of your trading window, providing a constant visual guide regardless of how the price moves left or right on the screen.
Key Benefits for Traders
- Consistency: By automating the placement of these lines, you ensure that your key levels remain perfectly steady and don't shift accidentally.
- Customization: Because each of the eight lines can have its own unique color and thickness, it is easy to create a customized "map" of the market at a glance.
- Cleanliness: The script handles the technical work of creating and maintaining the objects on your chart, keeping your workspace organized and focused on price action.
//+------------------------------------------------------------------+
//| DrawLine.mq4 |
//| by yangelong 08.07.04|
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
extern int price1=0;
extern color color1=Yellow;
extern int width1=1;
extern int price2=0;
extern color color2=Yellow;
extern int width2=1;
extern int price3=0;
extern color color3=Yellow;
extern int width3=1;
extern int price4=0;
extern color color4=Yellow;
extern int width4=1;
extern int price5=0;
extern color color5=Yellow;
extern int width5=1;
extern int price6=0;
extern color color6=Yellow;
extern int width6=1;
extern int price7=0;
extern color color7=Yellow;
extern int width7=1;
extern int price8=0;
extern color color8=Yellow;
extern int width8=1;
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if(price1!=0)
{
ObjectCreate("price1", OBJ_HLINE, 0, Time[0], price1);
ObjectSet("price1",OBJPROP_COLOR,color1);
ObjectSet("price1",OBJPROP_WIDTH,width1);
}
if(price2!=0)
{
ObjectCreate("price2", OBJ_HLINE, 0, Time[0], price2);
ObjectSet("price2",OBJPROP_COLOR,color2);
ObjectSet("price2",OBJPROP_WIDTH,width2);
}
if(price3!=0)
{
ObjectCreate("price3", OBJ_HLINE, 0, Time[0], price3);
ObjectSet("price3",OBJPROP_COLOR,color3);
ObjectSet("price3",OBJPROP_WIDTH,width3);
}
if(price4!=0)
{
ObjectCreate("price4", OBJ_HLINE, 0, Time[0], price4);
ObjectSet("price4",OBJPROP_COLOR,color4);
ObjectSet("price4",OBJPROP_WIDTH,width4);
}
if(price5!=0)
{
ObjectCreate("price5", OBJ_HLINE, 0, Time[0], price5);
ObjectSet("price5",OBJPROP_COLOR,color5);
ObjectSet("price5",OBJPROP_WIDTH,width5);
}
if(price6!=0)
{
ObjectCreate("price6", OBJ_HLINE, 0, Time[0], price6);
ObjectSet("price6",OBJPROP_COLOR,color6);
ObjectSet("price6",OBJPROP_WIDTH,width6);
}
if(price7!=0)
{
ObjectCreate("price7", OBJ_HLINE, 0, Time[0], price7);
ObjectSet("price7",OBJPROP_COLOR,color7);
ObjectSet("price7",OBJPROP_WIDTH,width7);
}
if(price8!=0)
{
ObjectCreate("price8", OBJ_HLINE, 0, Time[0], price8);
ObjectSet("price8",OBJPROP_COLOR,color8);
ObjectSet("price8",OBJPROP_WIDTH,width8);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments