Price_Range_HLClMdz

Author: Grigori Minassian
Price_Range_HLClMdz

This tool is designed to analyze and visualize the price movement of an asset by measuring how much it fluctuates relative to a specific starting point over a set period. Instead of just looking at the current price, it evaluates the "range" or "stretch" of the market behavior to provide a clearer picture of volatility and trend direction.

How the Logic Works

1. Defining the Look-Back Window The script operates based on a user-defined timeframe (the period). It looks back at a specific number of previous candles to establish a baseline. This allows the tool to understand the recent "neighborhood" of price action rather than just reacting to what is happening at this exact second.

2. Identifying Key Price Points For every point on the chart, the logic automatically scans the look-back window to identify three critical pieces of information:

  • The Highest Price reached during that time.
  • The Lowest Price reached during that time.
  • The Current Closing Price.

It then compares these values against the price at the very beginning of that timeframe to calculate how far the price has moved upward, downward, or stayed steady.

3. Calculating the "Midpoint" Balance A core part of this script's logic is finding the mathematical center of the price movement. By averaging the distance from the High and the distance from the Low, it determines a "Middle" value. This serves as a balancing point for the price range.

4. Measuring Deviation (Relative Movement) Once the midpoint is established, the script calculates how far away the High, Low, and Close prices are from that center. This effectively "normalizes" the data. Instead of showing you raw prices, it shows you:

  • The distance of the high above the average range.
  • The distance of the low below the average range.
  • Where the current closing price sits in relation to that average range.

Summary for the User

Essentially, this indicator takes a chaotic set of price movements and simplifies them into a measured range. It tells you not just where the price is, but how far it has stretched away from its recent average behavior. By visualizing these relative distances, it helps traders identify whether the market is overextending in one direction or remaining balanced within its recent boundaries.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Price_Range_HLClMdz
//+------------------------------------------------------------------+
//|                                              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 3
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Green
//#property  indicator_color4  Gray

//#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()
{
   IndicatorBuffers(4);

   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, ChangeClose);
   SetIndexBuffer(3, ChangeMid);

   IndicatorDigits(Digits + 1);

   IndicatorShortName("Price Range HLClMid (" + PR_Period + ") ");
   SetIndexLabel(0, "High");
   SetIndexLabel(1, "Low");
   SetIndexLabel(2, "Close");
//   SetIndexLabel(3, "Middle");
   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);
      ChangeMid[i]   = (price_change_high+price_change_low)/2;
      ChangeHigh[i]  = price_change_high-ChangeMid[i];
      ChangeLow[i]   = price_change_low-ChangeMid[i];
      ChangeClose[i] = price_change_close-ChangeMid[i];
   }
   
   return(0);
}

Comments