PChannel

This script is a custom technical analysis tool designed for the MetaTrader platform to help traders visualize price boundaries and market equilibrium. It functions by identifying specific price levels over a set period, allowing you to see the "territory" currently occupied by the market.

How it Works

The logic of this indicator relies on three primary components that are calculated based on a user-defined timeframe (the "Range"). By default, this range is set to 14 periods, but it can be adjusted to suit different trading styles.

1. The Upper Boundary (Up Channel) The script constantly scans the price history over the specified range to find the highest point reached. It then projects this maximum price as a line on your chart. This represents the "ceiling" of recent market activity, showing you the strongest resistance level the price has encountered lately.

2. The Lower Boundary (Down Channel) Simultaneously, the script identifies the lowest price point within that same range. It projects this as a second line, representing the "floor." This helps traders identify the primary support level where the market has recently bounced back upward.

3. The Median Line (Middle Channel) Once the upper and lower boundaries are established, the script performs a simple calculation to find the exact midpoint between them. It draws a third line on your chart to represent this center point. This acts as an equilibrium marker, helping you determine if the price is currently trading in the upper half (potentially overextended) or the lower half (potentially undervalued) of its recent range.

Summary for Traders

Essentially, this tool creates a visual "channel" on your screen. Instead of looking at raw, scattered price data, it simplifies the market into a clear structure:

  • The Top: Where the price hit its peak recently.
  • The Bottom: Where the price hit its lowest point recently.
  • The Middle: The balanced center of the current trading zone.

By watching how the price moves relative to these three lines, you can better understand the current volatility and identify potential areas where the price might face resistance or find support.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
PChannel
//+------------------------------------------------------------------+
//|                                                   PChannel_m.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window //Íàçíà÷àåì îêíî äëÿ âûâîäà ãðàôèêà (òàì, ãäå áàðû)
#property indicator_buffers 3 //Âûäåëÿåì äëÿ èíäèêàòîðà òðè áóôåðà
#property indicator_color1 DodgerBlue //Íàçíà÷àåì öâåò äëÿ îòîáðàæåíèÿ äàííûõ 1 áóôåðà
#property indicator_color2 DodgerBlue //Íàçíà÷àåì öâåò äëÿ îòîáðàæåíèÿ äàííûõ 2 áóôåðà
#property indicator_color3 DodgerBlue //Íàçíà÷àåì öâåò äëÿ îòîáðàæåíèÿ äàííûõ 3 áóôåðà
//---- input parameters //îáúÿâëåíèå ââîäèìûõ âíåøíèõ ïàðàìåòðîâ
extern int Range=14; //ïî óìîë÷àíèþ ââîäèìîå çíà÷åíèå ðàâíî 14
//---- buffers
double UpBuffer[]; //îáÿâëåíèå ïåðåìåííîé UpBuffer òèïà "ìàññèâ ñ ïëàâàþùåé òî÷êîé"
double DnBuffer[]; //îáÿâëåíèå ïåðåìåííîé DnBuffer òèïà "ìàññèâ ñ ïëàâàþùåé òî÷êîé"
double MdBuffer[]; //îáÿâëåíèå ïåðåìåííîé MdBuffer òèïà "ìàññèâ ñ ïëàâàþùåé òî÷êîé"
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() //èíèöèàëèçàöèÿ ïåðåìåííûõ
  {
   string short_name; //îáÿâëåíèå ïåðåìåííîé short_name òèïà "ñòðîêîâûé"
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,1,2); //óñòàíîâêà ñòèëÿ äëÿ ïåðâîãî çíà÷åíèÿ èíäèêàòîðà
   SetIndexStyle(1,DRAW_LINE,1,2); //óñòàíîâêà ñòèëÿ äëÿ âòîðîãî çíà÷åíèÿ èíäèêàòîðà
   SetIndexStyle(2,DRAW_LINE,2); //óñòàíîâêà ñòèëÿ äëÿ òðåòüåãî çíà÷åíèÿ èíäèêàòîðà
   SetIndexBuffer(0,UpBuffer); //çíà÷åíèå çàïèñûâàåìîå â 0 áóôåð ðàâíî ïåðåìåííîé UpBuffer
   SetIndexBuffer(1,DnBuffer); //çíà÷åíèå çàïèñûâàåìîå â 1 áóôåð ðàâíî ïåðåìåííîé DnBuffer
   SetIndexBuffer(2,MdBuffer); //çíà÷åíèå çàïèñûâàåìîå â 2 áóôåð ðàâíî ïåðåìåííîé MdBuffer
//---- name for DataWindow and indicator subwindow label
   short_name="PriceChannel("+Range+")";  //ïåðåìåííîé short_name ïðèñâàèâàåì ñòðîêîâîå
                                                  //çíà÷åíèå ðàâíîå âûðàæåíèþ
   IndicatorShortName(short_name);  //äëÿ îòîáðàæåíèÿ íà ãðàôèêå ïðèñâîèì èíäèêàòîðó êðàòêîå
                                    //íàèìåíîâàíèå
   SetIndexLabel(0,"Up Channel");   //äëÿ îòîáðàæåíèÿ íà ãðàôèêå ïðèñâîèì ìåòêå îòîáðàæàþùåé
                                    //çíà÷åíèÿ 0 áóôåðà èìÿ Up Channel
   SetIndexLabel(1,"Down Channel"); //äëÿ îòîáðàæåíèÿ íà ãðàôèêå ïðèñâîèì ìåòêå îòîáðàæàþùåé
                                    //çíà÷åíèÿ 1 áóôåðà èìÿ Down Channel
   SetIndexLabel(2,"Middle Channel"); //äëÿ îòîáðàæåíèÿ íà ãðàôèêå ïðèñâîèì ìåòêå îòîáðàæàþùåé
                                      //çíà÷åíèÿ 2 áóôåðà èìÿ Middle Channel
//----
   SetIndexDrawBegin(0,0); //óñòàíîâêà íà÷àëüíîé òî÷êè ïðîðèñîâêè äëÿ 0 áóôåðà
   SetIndexDrawBegin(1,0); //óñòàíîâêà íà÷àëüíîé òî÷êè ïðîðèñîâêè äëÿ 1 áóôåðà
   SetIndexDrawBegin(2,0); //óñòàíîâêà íà÷àëüíîé òî÷êè ïðîðèñîâêè äëÿ 2 áóôåðà
//----
   return(0); //âîçâðàò èç ñåêöèè èíèöèàëèçàöèè
  }
//+------------------------------------------------------------------+
//| PriceChannel                                                     |
//+------------------------------------------------------------------+
int start() //íà÷àëî ïðîãðàììû (ðàñ÷åòà)
  {
   int i; //îáúÿâëåíèå öåëî÷èñëåííîé ïåðåìåííîé i,k,sch

//----
   
   for(i=Bars-1;i>=0;i--)
   {
      UpBuffer[i]=High[Highest(NULL,0,MODE_HIGH,Range,i)];
      DnBuffer[i]=Low[Lowest(NULL,0,MODE_LOW,Range,i)];
      MdBuffer[i]=(UpBuffer[i]+DnBuffer[i])/2;
   }
   return(0);
  }
//+------------------------------------------------------------------+

Comments