This script is designed to automate the visual organization of your trading chart by dynamically generating a series of horizontal support or resistance lines. It helps traders visualize specific price levels based on a customizable "staircase" logic, allowing for a clearer view of potential entry points or target zones.
Core Functionality
The primary purpose of this tool is to create ten distinct horizontal lines on your chart. Instead of placing these lines manually one by one, the script calculates their positions automatically based on a base starting point and a series of defined "steps."
How It Works
- The Anchor Point: The script begins with a primary reference line (labeled as
b_order0). This acts as the "anchor" or the base price from which all other lines are measured. - Dynamic Spacing: Rather than placing every line at an equal distance, the script uses a cumulative step system. Each subsequent line is placed at a specific distance away from the previous ones, determined by the user-defined input values (Step 1 through Step 9).
- Cumulative Logic: The logic follows a progressive addition. For example, the second line is placed at one "step" away from the anchor, while further lines are placed at the sum of multiple preceding steps. This creates a structured visual layout where the spacing between lines can be wider or narrower depending on your settings.
- Real-Time Updates: The script is designed to keep these lines relevant. It continuously checks the position of the anchor line and recalculates the placement of the other nine lines to ensure they remain perfectly aligned with the requested intervals.
Visual Presentation
- Consistency: All generated lines are rendered in a uniform "Medium Blue" color to maintain a clean and professional look on your workspace.
- Clean Up: To keep your chart organized, the script includes an automatic cleanup feature. When you remove the indicator from your chart, it automatically deletes all ten lines, ensuring that no unnecessary objects are left behind.
Summary for Traders
This tool is ideal for traders who prefer to see a pre-calculated grid of price levels. By adjusting the "Step" inputs, you can customize the layout to match your specific trading strategy—whether you need tightly packed lines for scalping or wider intervals for swing trading. It removes the manual effort of drawing multiple horizontal lines and ensures mathematical precision across your entire visual workspace.
//+------------------------------------------------------------------+
//| Lines_buy.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://pilot911.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, pilot@m-lan.ru"
#property link "pilot@m-lan.ru"
//----
#property indicator_chart_window
//---- input parameters
extern double StartFrom=1.20;
extern double Step1=20;
extern double Step2=40;
extern double Step3=80;
extern double Step4=80;
extern double Step5=80;
extern double Step6=80;
extern double Step7=80;
extern double Step8=80;
extern double Step9=80;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double curr=NormalizeDouble(ObjectGet( "b_order0", OBJPROP_PRICE1),Digits);
//----
ObjectSet( "b_order1", OBJPROP_PRICE1, curr+Step1*Point);
ObjectSet( "b_order2", OBJPROP_PRICE1, curr+(Step1+Step2)*Point);
ObjectSet( "b_order3", OBJPROP_PRICE1, curr+(Step1+Step2)*Point);
ObjectSet( "b_order4", OBJPROP_PRICE1, curr+(Step1+Step2+Step3)*Point);
ObjectSet( "b_order5", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4)*Point);
ObjectSet( "b_order6", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4+Step5)*Point);
ObjectSet( "b_order7", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4+Step5+Step6)*Point);
ObjectSet( "b_order8", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4+Step5+Step6+Step7)*Point);
ObjectSet( "b_order9", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4+Step5+Step6+Step7+Step8)*Point);
ObjectSet( "b_order10", OBJPROP_PRICE1, curr+(Step1+Step2+Step3+Step4+Step5+Step6+Step7+Step8+Step9)*Point);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
ObjectCreate( "b_order0", OBJ_HLINE, 0, 0, StartFrom, 0, 0, 0, 0 );
ObjectSet( "b_order0", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order1", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order1", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order2", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order2", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order3", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order3", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order4", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order4", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order5", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order5", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order6", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order6", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order7", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order7", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order8", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order8", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order9", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order9", OBJPROP_COLOR, MediumBlue );
ObjectCreate( "b_order10", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "b_order10", OBJPROP_COLOR, MediumBlue );
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete( "b_order0");
ObjectDelete( "b_order1");
ObjectDelete( "b_order2");
ObjectDelete( "b_order3");
ObjectDelete( "b_order4");
ObjectDelete( "b_order5");
ObjectDelete( "b_order6");
ObjectDelete( "b_order7");
ObjectDelete( "b_order8");
ObjectDelete( "b_order9");
ObjectDelete( "b_order10");
return(0);
}
//+------------------------------------------------------------------+
Comments