Lines_buy(1)
Download scriptThis script is designed for the MetaTrader 4 platform to automate the visual organization of price levels on a trading chart. Its primary purpose is to create a structured "ladder" of horizontal lines, which helps traders visualize potential entry points or target zones based on specific mathematical increments.
Core Functionality
The tool operates by generating a sequence of eleven horizontal lines (labeled b_order0 through b_order10) on your trading screen. Here is how the logic flows:
- Initial Setup: When you first load the script, it identifies a starting price point. It then places a series of horizontal lines across the chart. All these lines are automatically colored in "Medium Blue" to ensure they are clearly visible against the standard chart background.
- Dynamic Spacing: The script uses a specific set of distance measurements (referred to as "Steps"). Instead of placing every line at the same distance from each other, the logic calculates the position of each subsequent line by adding these steps cumulatively.
- For example, the second line is placed at a short distance from the first.
- The third line is placed further away, calculated by combining the distances of the previous two steps.
- This continues until all ten secondary lines are mapped out, creating a graduated visual scale.
- Real-Time Positioning: The script is designed to reference the price of a primary "base" line (
b_order0). It calculates the location of all other lines relative to this base. This allows for a structured layout where the distance between lines can be customized via the settings menu. - Automatic Cleanup: To keep your trading workspace clean, the script includes a "deinitialization" process. This means that as soon as you remove the script from the chart, it automatically deletes all eleven horizontal lines it created, returning your chart to its original state without leaving behind any clutter.
How it Benefits the User
This tool is essentially a visual planning aid. By defining specific "Steps," a trader can quickly see a pre-calculated grid of price levels. It removes the manual work of drawing multiple lines one by one and ensures that the mathematical spacing between your potential trade zones remains consistent and precise.
//+------------------------------------------------------------------+
//| 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