Waist_Close_Levels
Download scriptThis tool is designed to provide visual clarity on your trading charts by automatically identifying and plotting two specific price benchmarks based on historical daily data. It helps traders visualize where the market "closed" and where its "center" was during previous trading sessions.
How the Logic Works
The script looks back over a user-defined number of days (defaulting to 10) to analyze the price action of completed daily candles. For each of these past days, it performs two specific calculations:
- The Closing Level: It identifies the exact price at which the previous day's trading session ended.
- The Waist Level: It calculates the "midpoint" of the day's movement by averaging the opening price and the closing price. This represents the mathematical center of that day's price range.
Visual Presentation
Instead of cluttering your screen with endless data, the script neatly organizes these levels into horizontal lines on your chart:
- Dynamic Mapping: The tool automatically places these lines on the correct dates so you can see the progression of these levels over time.
- Customizable Appearance: You can easily adjust the colors and line styles for both the "Closing Level" and the "Waist Level" to match your specific chart theme.
- Clean Environment: The script is designed to manage itself—it clears old data automatically so that only the relevant number of days you've requested remain visible, keeping your workspace organized.
Summary for Traders
By visualizing these levels, you can better understand where previous market participants "settled" and where the equilibrium point was for past sessions. This provides a historical context that can help in identifying potential support, resistance, or balance zones in the current market.
//+------------------------------------------------------------------+
//| Waist_Close_Levels .mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property link " AllPivots by IgorAD Modified by cja"
#property indicator_chart_window
extern int CountDays=10;
extern color Waist = Lime;
extern int Waist_Style = 1;
extern color Y_Close = Yellow;
extern int Y_Close_Style = 1;
datetime time1;
datetime time2;
double open,close,high,low;
double Yc,Wst;
int shift, num;
void ObjDel()
{
for (;num<=CountDays;num++)
{
ObjectDelete("Yc["+num+"]");
ObjectDelete("Wst["+num+"]");
}
}
void PlotLine(string name,double value,double line_color,double style)
{
ObjectCreate(name,OBJ_TREND,0,time1,value,time2,value);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_STYLE, style);
ObjectSet(name, OBJPROP_RAY, false);
ObjectSet(name, OBJPROP_BACK, true);
ObjectSet(name, OBJPROP_COLOR, line_color);
}
int init()
{
return(0);
}
int deinit()
{
ObjDel();
Comment("");
return(0);
}
int start()
{
int i;
ObjDel();
num=0;
for (shift=CountDays-1;shift>=0;shift--)
{
time1=iTime(NULL,PERIOD_D1,shift);
i=shift-1;
if (i<0)
time2=Time[0];
else
time2=iTime(NULL,PERIOD_D1,i)-Period()*60;
high = iHigh(NULL,PERIOD_D1,shift+1);
low = iLow(NULL,PERIOD_D1,shift+1);
open = iOpen(NULL,PERIOD_D1,shift+1);
close = iClose(NULL,PERIOD_D1,shift+1);
Yc = (close);
Wst = ((open+close)/2);
time2=time1+PERIOD_D1*60;
num=shift;
PlotLine("Yc["+num+"]",Yc,Y_Close,Y_Close_Style);
PlotLine("Wst["+num+"]",Wst,Waist,Waist_Style);
}
return(0);
}
//+------------------------------------------------------------------+
Comments