PriceActionChanel

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
PriceActionChanel

This technical tool is designed to provide a visual representation of price boundaries on a trading chart. It functions by calculating two distinct lines—an upper boundary and a lower boundary—that move in tandem with the market price, helping traders identify potential zones of overextension or support and resistance.

Core Logic and Functionality

The script operates based on the following logic:

  • Moving Average Foundation: The tool uses a Smoothed Moving Average (SMMA) as its core mathematical engine. Instead of looking at the standard closing price, it specifically tracks the "High" and "Low" price points of each bar to determine the market's range.
  • The Deviation Mechanism: The primary purpose of this script is to create an "envelope" around the market price. It takes the calculated moving averages and expands (or contracts) them based on a user-defined percentage known as "Deviation."
  • Upper and Lower Bound Calculation:
    • The Upper Envelope: This line is calculated by taking the Moving Average of the High prices and adding a percentage of deviation to it.
    • The Lower Envelope: This line is calculated by taking the Moving Average of the Low prices and subtracting a percentage of deviation from it.
  • Visual Output: These two lines are plotted simultaneously on the chart. Because they are linked to the moving average of the highs and lows, they create a "channel" or "tunnel."

How it is Used in Analysis

By observing where the current market price sits in relation to these envelopes, users can interpret market behavior:

  1. Volatility Mapping: The wider the gap between the upper and lower lines, the higher the volatility in the market.
  2. Price Extremes: When the market price pushes toward or outside of the upper envelope, it may indicate that the asset is becoming "overbought" or stretched. Conversely, touching the lower envelope may suggest the asset is becoming "oversold."
  3. Trend Identification: The sloping direction of the envelopes helps in identifying the prevailing trend; if the entire channel is moving upward, the market is in a bullish phase, while a downward slope indicates a bearish phase.

Customizable Parameters

The script allows for several adjustments to fine-tune how these boundaries appear:

  • Period: Adjusts how many past bars are considered when calculating the average (higher numbers result in smoother, slower lines).
  • Deviation: Determines how far the upper and lower lines sit away from the moving average center.
  • Shift: Allows the user to move the entire visual indicator forward or backward on the chart for different perspectives.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
PriceActionChanel
//+------------------------------------------------------------------+
//|                                                    Envelopes.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                     www.forex-tsd.com  http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net    www.forex-tsd.com"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Goldenrod
//---- indicator parameters
extern int MA_Period=5;
extern int MA_Shift=0;
extern int MA_Method=2;
extern int Applied_Price=0;
extern double Deviation=0.0;
/*************************************************************************
---------------------------------------
PRICE_CLOSE    0 Close price. 
PRICE_OPEN     1 Open price. 
PRICE_HIGH     2 High price. 
PRICE_LOW      3 Low price. 
PRICE_MEDIAN   4 Median price, (high+low)/2. 
PRICE_TYPICAL  5 Typical price, (high+low+close)/3. 
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 
You must use the numeric value of the Applied Price that you want to use
when you set the 'applied_price' value with the indicator inputs.
---------------------------------------
MODE_SMA    0 Simple moving average, 
MODE_EMA    1 Exponential moving average, 
MODE_SMMA   2 Smoothed moving average, 
MODE_LWMA   3 Linear weighted moving average. 
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.

**************************************************************************/

//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
   string short_name;
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexShift(0,MA_Shift);
   SetIndexShift(1,MA_Shift);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   if(MA_Period<2) MA_Period=14;
   draw_begin=MA_Period-1;
//---- indicator short name
   IndicatorShortName("PAC("+MA_Period+")");
   SetIndexLabel(0,"Env("+MA_Period+")Upper");
   SetIndexLabel(1,"Env("+MA_Period+")Lower");
   SetIndexDrawBegin(0,draw_begin);
   SetIndexDrawBegin(1,draw_begin);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   if(Deviation<0) Deviation=0;
   if(Deviation>100.0) Deviation=100.0;
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   limit=Bars-ExtCountedBars;
//---- EnvelopesM counted in the buffers
   for(int i=0; i<limit; i++)
     { 
      ExtMapBuffer1[i] = (1+Deviation/100)*iMA(NULL,0,MA_Period,0,MODE_SMMA,PRICE_HIGH,i);
      ExtMapBuffer2[i] = (1-Deviation/100)*iMA(NULL,0,MA_Period,0,MODE_SMMA,PRICE_LOW,i);
     }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments