Price_Range_hhll

Download script
Author: Grigori Minassian
Price_Range_hhll

This tool is designed to provide a visual representation of how much an asset's price has moved relative to its starting point over a specific timeframe. Instead of looking at just the final price, it breaks down the volatility and movement into three distinct components: the peak (High), the floor (Low), and the current result (Close).

Core Functionality

The script analyzes your chosen chart based on a user-defined time window (the "Period"). For every candle on your chart, the logic performs the following steps:

  • Establishing a Baseline: It identifies the starting price at the beginning of the designated period. This acts as the "anchor" point for all calculations.
  • Identifying Extremes: Within that same period, the script scans to find the highest and lowest closing prices reached.
  • Calculating Variance: It measures the distance between those extremes and the starting baseline. Essentially, it calculates how far "up" or "down" the price traveled from where it began.

Visual Output

The data is presented in a separate window below your main chart, plotted as three distinct lines:

  1. The High Line (Blue): Shows the maximum positive movement relative to the starting point. It illustrates the highest level of optimism or "peak" reached during that timeframe.
  2. The Low Line (Red): Shows the maximum negative movement relative to the starting point. This represents the deepest "dip" or the furthest extent of a downward move.
  3. The Close Line (Green): Shows the net result. It tracks where the price actually ended up compared to where it started, allowing you to see if the current position is closer to the peak, the floor, or somewhere in between.

Key Benefits

By normalizing these movements into a "change" value, the indicator removes the noise of absolute pricing and focuses purely on relative motion. This allows traders to quickly assess the range of volatility for any given period and see how much of that total available range has been covered by the current price action.

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_hhll
//+------------------------------------------------------------------+
//|                                                  Price Range.mq4 |
//|                                                Grigori Minassian |
//+------------------------------------------------------------------+
#property copyright "Grigori Minassian"


#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Blue
#property  indicator_color2  Green
#property  indicator_color3  Red
#property  indicator_width1  1
#property  indicator_width3  1


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


extern int PR_Period = 60;


int init()
{

   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(0, ChangeHigh);
   SetIndexBuffer(1, ChangeClose);
   SetIndexBuffer(2, ChangeLow);
   
   IndicatorDigits(Digits + 1);

   IndicatorShortName("Price Range(" + PR_Period + ")");
   SetIndexLabel(0, "High");
   SetIndexLabel(1, "Close");
   SetIndexLabel(2, "Low");
   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_CLOSE, period, shift);
   int low_shift  = iLowest(Symbol(), 0, MODE_CLOSE, 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;
      ChangeClose[i] = price_change_close;
      ChangeLow[i] = price_change_low;
   }
   
   return(0);
}

Comments