Price Channel_v2

Download script
Price Channel_v2

The Price Channel indicator is designed to provide traders with a visual representation of the price range over a specific period. Instead of relying on complex mathematical formulas or lagging oscillators, it focuses on the raw movement of the market to define the "boundaries" of current price action.

How the Logic Works

The core functionality of this tool revolves around identifying the highest and lowest prices reached during a fixed timeframe (the "Channel Period"). Here is a breakdown of how it processes data:

1. Establishing the Range Boundaries The script scans back through the chart for a set number of previous candles (defined by the user). During this look-back period, it identifies two critical points:

  • The Upper Boundary: The highest price reached at any point within that window.
  • The Lower Boundary: The lowest price reached at any point within that window.

2. Dynamic Tracking As new candles form, the indicator continuously updates these boundaries. This means the "channel" is not static; it expands or contracts based on the volatility of the market. If a new high is made, the upper boundary rises; if a new low is made, the lower boundary drops.

3. Calculating the Median Line In addition to the top and bottom boundaries, the script automatically calculates a "Middle Channel." This is determined by taking the exact average of the current High and Low points. This serves as a central equilibrium point, helping traders visualize the midpoint of the price swing.

Visual Representation

The indicator plots three distinct lines on your chart:

  • Up Channel: Represents the ceiling of the recent price action.
  • Down Channel: Represents the floor of the recent price action.
  • Middle Channel: Represents the balanced center between the ceiling and the floor.

Practical Application

By using this logic, traders can easily visualize the "trading zone" for a specific period. It helps in identifying:

  • Support and Resistance: The Upper and Lower channels act as visual markers for where price has historically struggled to move past.
  • Volatility: A wide gap between the Upper and Lower lines indicates high volatility, while a narrow gap suggests a period of consolidation or "sideways" trading.
  • Trend Direction: By observing whether the price is consistently hugging the upper boundary or the lower boundary, traders can better gauge the prevailing momentum of the market.
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Price Channel_v2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                Price Channel.mq4 |
//|                                                                  |
//|                                       http://forex.kbpauk.ru/    |
//+------------------------------------------------------------------+
 
#property link      "http://forex.kbpauk.ru/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 DodgerBlue
#property indicator_color3 DodgerBlue
//---- input parameters
extern int ChannelPeriod=14;
//---- buffers
double UpBuffer[];
double DnBuffer[];
double MdBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE,2);
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
   SetIndexBuffer(2,MdBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="Price Channel("+ChannelPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Up Channel");
   SetIndexLabel(1,"Down Channel");
   SetIndexLabel(2,"Middle Channel");
//----
   SetIndexDrawBegin(0,ChannelPeriod);
   SetIndexDrawBegin(1,ChannelPeriod);
   SetIndexDrawBegin(2,ChannelPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Price Channel                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
   int    k;
   double high,low,price;
//----
   if(Bars<=ChannelPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=ChannelPeriod;i++) UpBuffer[Bars-i]=0.0;
//----
   i=Bars-ChannelPeriod-1;
   if(counted_bars>=ChannelPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
       high=High[i]; low=Low[i]; k=i-1+ChannelPeriod;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        } 
     UpBuffer[i]=high;
     DnBuffer[i]=low;
     MdBuffer[i]=(high+low)/2;
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments