This tool is designed to automatically identify and plot significant price boundaries on your trading chart by tracking the highest and lowest prices reached during specific daily sessions. It simplifies how you view market volatility by creating a "channel" of price action, helping you visualize the extremes of the current day's movement.
How it Works
The script operates by scanning the price history and identifying key milestones based on time:
- Daily Reset Mechanism: The logic is programmed to recognize the end of a trading day (specifically looking at late evening hours). Once it detects the transition into a new day, it resets its tracking.
- Starting Point: At the beginning of each new day (specifically during the first 30 minutes of the session), the tool captures the opening high and low prices to establish the starting boundaries of that day's channel.
- Dynamic Tracking: As the trading day progresses, the script continuously monitors every new price movement. If the market hits a new high or drops to a new low, the tool automatically updates its boundaries. It essentially "stretches" the channel to accommodate the widest range of price action seen so far.
- Average Calculation: In addition to tracking the top and bottom limits, the tool calculates a middle line representing the average between the current high and low.
Visual Representation
The script draws three distinct lines on your chart to provide a comprehensive overview:
- Upper Channel (High): Represents the highest price reached during the current session.
- Lower Channel (Low): Represents the lowest price reached during the current session.
- Average Channel: A median line that sits exactly halfway between the high and low, providing a central reference point for the day's volatility.
On-Screen Information
To provide you with real-time data without needing to manually calculate figures, the tool displays a summary comment directly on your chart. This includes:
- The current High price.
- The current Low price.
- The current Average price.
- The total Channel Width, which tells you exactly how many points (or pips) the price has moved between its daily extremes.
//+------------------------------------------------------------------+
//| DayChannel.mq4 |
//| Ãîøà Øìåëü |
//| http://www.system32.ru |
//+------------------------------------------------------------------+
#property copyright "Ãîøà Øìåëü"
#property link "http://www.system32.ru"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 Blue
double shifthigh[];
double shiftlow[];
double shiftaver[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE, 0,2);
SetIndexBuffer(0,shifthigh);
SetIndexLabel(0,"Up Channel");
SetIndexDrawBegin(0,0);
SetIndexStyle(1,DRAW_LINE, 0,2);
SetIndexBuffer(1,shiftlow);
SetIndexLabel(1,"Down Channel");
SetIndexDrawBegin(1,0);
SetIndexStyle(2,DRAW_LINE, 0,2);
SetIndexBuffer(2,shiftaver);
SetIndexLabel(2,"Average Channel");
SetIndexDrawBegin(2,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
double LowLine=0;
double HighLine=0;
double AverLine=0;
//----
int ww=0;
for (i=(Bars-1);i>0;i--)
{
if (((TimeHour(Time[i])== 23) && (TimeMinute(Time[i]) < 59))
|| ((TimeDayOfWeek(Time[i])== 5) && (TimeHour(Time[i])== 22) && (TimeMinute(Time[i]) < 59)))
ww=0;
if (TimeHour(Time[i])== 0 && TimeMinute(Time[i]) >= 0 && TimeMinute(Time[i]) <= 30 && ww == 0)
{
LowLine=iLow(Symbol(),NULL,i);
HighLine=iHigh(Symbol(),NULL,i);
ww=1;
}
else
{
if (iLow(Symbol(),NULL,i) < LowLine) LowLine = iLow(Symbol(),NULL,i);
if (iHigh(Symbol(),NULL,i) > HighLine) HighLine = iHigh(Symbol(),NULL,i);
}
AverLine=LowLine+(HighLine-LowLine)/2;
shiftlow[i]=LowLine;
shifthigh[i]=HighLine;
shiftaver[i]=AverLine;
}
Comment(" Õàé - ", HighLine,"; Ëîó - ",LowLine, "; ÄÑ - ",AverLine,"; Øèðèíà êàíàëà=",(HighLine-LowLine)*(1/Point));
//----
return(0);
}
//+------------------------------------------------------------------+
Comments