This script is a specialized visual tool designed for the MetaTrader trading platform to help traders automatically organize and visualize a series of sell-side price levels on their charts. Instead of manually drawing multiple lines, this tool automates the placement of a "grid" of price markers based on specific mathematical distances.
How It Works
The logic of the script can be broken down into three main phases:
1. Initialization (Setup) When you first apply the script to your chart, it prepares eleven distinct horizontal lines. It sets a primary reference point (a "starting line") and creates ten additional lines underneath it. All these lines are colored red by default to ensure they stand out clearly against the price action.
2. Dynamic Spacing Calculation The tool uses a custom "stepping" system to determine where each line should appear. Rather than placing every line at equal intervals, it allows for varying gaps:
- It identifies a base price point (the primary reference line).
- It then calculates the positions of the subsequent lines by subtracting specific "Step" values from that base price.
- For example, the first few lines are placed at relatively close intervals, while the final lines are pushed further down the chart at wider gaps. This allows a trader to visualize different zones of potential interest—closer clusters for immediate price action and wider gaps for deeper retracements.
3. Real-Time Adjustment The script is designed to be reactive. It constantly monitors the position of the primary reference line (s_order0). If that main line is moved manually by the user on the chart, the script automatically recalculates and repositions all ten secondary lines instantly. This ensures that the entire "ladder" of price levels moves in perfect synchronization with your primary anchor point.
Summary for the User
Essentially, this is a dynamic grid generator. You set your main price level, and the script automatically builds a proportional ladder of sell levels below it. It eliminates the tedious work of manual drawing and ensures that your technical analysis remains consistent, as all your secondary price levels will always maintain their exact mathematical relationship to your primary entry or target point.
//+------------------------------------------------------------------+
//| Lines_sell.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( "s_order0", OBJPROP_PRICE1),Digits);
//----
ObjectSet( "s_order1", OBJPROP_PRICE1, curr-Step1*Point);
ObjectSet( "s_order2", OBJPROP_PRICE1, curr-(Step1+Step2)*Point);
ObjectSet( "s_order3", OBJPROP_PRICE1, curr-(Step1+Step2)*Point);
ObjectSet( "s_order4", OBJPROP_PRICE1, curr-(Step1+Step2+Step3)*Point);
ObjectSet( "s_order5", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4)*Point);
ObjectSet( "s_order6", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4+Step5)*Point);
ObjectSet( "s_order7", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4+Step5+Step6)*Point);
ObjectSet( "s_order8", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4+Step5+Step6+Step7)*Point);
ObjectSet( "s_order9", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4+Step5+Step6+Step7+Step8)*Point);
ObjectSet( "s_order10", OBJPROP_PRICE1, curr-(Step1+Step2+Step3+Step4+Step5+Step6+Step7+Step8+Step9)*Point);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
ObjectCreate( "s_order0", OBJ_HLINE, 0, 0, StartFrom, 0, 0, 0, 0 );
ObjectSet( "s_order0", OBJPROP_COLOR, Red );
ObjectCreate( "s_order1", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order1", OBJPROP_COLOR, Red );
ObjectCreate( "s_order2", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order2", OBJPROP_COLOR, Red );
ObjectCreate( "s_order3", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order3", OBJPROP_COLOR, Red );
ObjectCreate( "s_order4", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order4", OBJPROP_COLOR, Red );
ObjectCreate( "s_order5", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order5", OBJPROP_COLOR, Red );
ObjectCreate( "s_order6", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order6", OBJPROP_COLOR, Red );
ObjectCreate( "s_order7", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order7", OBJPROP_COLOR, Red );
ObjectCreate( "s_order8", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order8", OBJPROP_COLOR, Red );
ObjectCreate( "s_order9", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order9", OBJPROP_COLOR, Red );
ObjectCreate( "s_order10", OBJ_HLINE, 0, 0, Ask, 0, 0, 0, 0 );
ObjectSet( "s_order10", OBJPROP_COLOR, Red );
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete( "s_order0");
ObjectDelete( "s_order1");
ObjectDelete( "s_order2");
ObjectDelete( "s_order3");
ObjectDelete( "s_order4");
ObjectDelete( "s_order5");
ObjectDelete( "s_order6");
ObjectDelete( "s_order7");
ObjectDelete( "s_order8");
ObjectDelete( "s_order9");
ObjectDelete( "s_order10");
return(0);
}
//+------------------------------------------------------------------+
Comments