Price_Range_HLClMd

Download script
Author: Grigori Minassian
Price_Range_HLClMd

The Price Range Mod. tool is designed to provide a visual representation of price volatility and movement relative to a specific starting point over a defined historical period. Instead of just looking at the current price, this indicator analyzes the "stretch" of the market—calculating how far the price has traveled upward and downward from where it began.

How the Logic Works

The indicator operates by looking back at a set number of bars (the "Period") on your chart. For every point in time, it performs the following calculations:

  • Establishing the Baseline: It identifies the closing price of the candle that occurred exactly one period ago. This acts as the "starting line" for the measurement.
  • Finding Extremes: The script automatically scans the recent history to find the highest peak and the lowest valley reached within that specific timeframe.
  • Measuring Displacement: It then calculates the distance (in points) between those peaks and valleys and the original baseline. This tells you how much "ground" the price has covered in both directions since it was last at that starting position.
  • Calculating the Midpoint: To provide a balanced view of the range, the tool calculates a middle value by averaging the highest and lowest displacement points.

What You See on the Chart

The indicator displays these measurements in a separate window below your main price chart. It plots four distinct data lines:

  1. High: Shows the maximum upward movement from the baseline.
  2. Low: Shows the maximum downward movement from the baseline.
  3. Middle: Represents the average "center" of the price range, helping to identify the median volatility.
  4. Close: Tracks the current price's progress relative to the baseline.

Summary for Traders

Essentially, this tool filters out minor market noise to show you the true magnitude of price swings. By visualizing the High, Low, Middle, and Close levels as a range, it allows you to see how aggressively the market is expanding or contracting relative to its recent history. It transforms raw price action into a measurable "map" of movement, making it easier to gauge the strength of a trend or the boundaries of a current trading range.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
Price_Range_HLClMd
//+------------------------------------------------------------------+
//|                                              Price Range Mod.mq4 |
//|                                      copyright Grigori Minassian |
//|                                          Rustem Bigeev modyfied  |
//|                                                    www.parch.ru  |
//+------------------------------------------------------------------+
//mod hlcl md

#property copyright "Grigori Minassian"
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Gray
#property  indicator_color4  Green

//#property  indicator_level1  0
#property  indicator_width3  1
#property  indicator_width4  1


double ChangeHigh[];
double ChangeClose[];
double ChangeLow[];
double ChangeMid[];

extern int PR_Period = 77;
extern bool showHL = true;
int init()
{
   int draw = DRAW_NONE; if (showHL)  draw = DRAW_LINE;
   SetIndexStyle(0, draw);
   SetIndexStyle(1, draw);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);

   SetIndexBuffer(0, ChangeHigh);
   SetIndexBuffer(1, ChangeLow);
   SetIndexBuffer(2, ChangeMid);
   SetIndexBuffer(3, ChangeClose);

   IndicatorDigits(Digits + 1);

   IndicatorShortName("Price Range HLClMid (" + PR_Period + ") ");
   SetIndexLabel(0, "High");
   SetIndexLabel(1, "Low");
   SetIndexLabel(2, "Middle");
   SetIndexLabel(3, "Close");
   return(0);
}

double price_change_high = 0;
double price_change_low = 0;
double price_change_close = 0;

void ComputePriceRange(int period, int shift)
{
   int high_shift = iHighest(Symbol(), 0, MODE_HIGH, period, shift);
   int low_shift  = iLowest (Symbol(), 0, MODE_LOW, period, shift);
   double price_open  = iClose(Symbol(), 0, period + shift);
   double price_high  = iClose(Symbol(), 0, high_shift);
   double price_low   = iClose(Symbol(), 0, low_shift);
   double price_close = iClose(Symbol(), 0, shift);
   
   price_change_high = (price_high - price_open) / Point;
   price_change_low = (price_low - price_open) / Point;
   price_change_close = (price_close - price_open) / Point;
}

int start()
{
   int i, limit;
   int counted_bars=IndicatorCounted();


   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;


   for(i = 0; i < limit; i++)
   {
      ComputePriceRange(PR_Period, i);
      ChangeHigh[i]  = price_change_high;
      ChangeLow[i]   = price_change_low;
      ChangeClose[i] = price_change_close;
      ChangeMid[i]   = (price_change_high+price_change_low)/2;
   }
   
   return(0);
}

Comments