PChannel_v1

Download script
Author: Copyright � 2005, Xaoc
PChannel_v1

This tool is designed to provide visual boundaries on a trading chart, helping traders identify the extremes of recent price action. It functions by creating two distinct lines—a "Top Band" and a "Bottom Band"—that map out the highest and lowest price points reached over a specific period.

How it Works

The logic behind this indicator is based on identifying the "peaks" and "valleys" of the market within a rolling window of time. Rather than following every small fluctuation, it looks back at a set number of previous candles (defined by the user) to find the absolute highest price reached and the absolute lowest price recorded during that timeframe.

Key Components

  • The Top Band: This line tracks the highest point achieved within the look-back period. It essentially tells you where the "ceiling" of the market was recently.
  • The Bottom Band: This line tracks the lowest point achieved within the same period, marking the "floor" of the market.
  • Dynamic Tracking: As new candles form on the chart, the indicator constantly updates these boundaries. If a new price peak is hit that is higher than any previous peak in the timeframe, the Top Band will move up to meet it. Conversely, if a new low is reached, the Bottom Band will shift downward.

Practical Purpose

For a trader, this script acts as a visual guide for market volatility and range. By observing these bands, you can see the immediate "territory" the price is currently trading within. It helps in identifying whether the price is hugging its recent limits or moving toward the middle of its established range, providing a clearer picture of the market's current boundaries.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
1 Favorites
PChannel_v1
//+------------------------------------------------------------------+
//|                                                     PChannel.mq4 |
//|                                           Copyright © 2005, Xaoc |
//|                                             http://forex.xcd.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Xaoc"
#property link      "http://forex.xcd.ru/"

#property indicator_chart_window
#property indicator_buffers 2 

#property indicator_color1 Blue 
#property indicator_color2 Red 

double topband[]; 
double botband[]; 

//---- input parameters
extern int       PCPeriod=55;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2); 
    
   SetIndexBuffer(0,topband); 
   SetIndexStyle(0, DRAW_LINE, EMPTY, 2, Blue); 
   SetIndexDrawBegin(0,2); 
   IndicatorShortName("PChan"); 
   SetIndexLabel(0,"TOPBAND");  
    
   SetIndexBuffer(1,botband); 
   SetIndexStyle(1, DRAW_LINE, EMPTY, 2, Red); 
   SetIndexDrawBegin(1,2); 
   SetIndexLabel(1,"BOTBAND");  
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    shift,counted_bars=IndicatorCounted(); 
   double lasthigh=0;
   double lastlow=0;
   //double ma40dbl; 
//---- TODO: add your code here 
   //ma40dbl=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,0); 

  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     //limit=Bars-counted_bars; 
  //---- main loop 
//---- main calculation loop 
   shift=Bars-1; 
   while(shift>=0) 
     { 
     topband[shift]=lasthigh;
     botband[shift]=lastlow;
     lasthigh=High[Highest(NULL,0,MODE_HIGH,PCPeriod,shift)];     
     lastlow=Low[Lowest(NULL,0,MODE_LOW,PCPeriod,shift)];
     shift--;//
     }
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments