Author: Copyright � 2005, Jason Robinson
Range_v3

The Range indicator is designed to provide a visual and analytical breakdown of price volatility by comparing the movement within current market candles against previous ones. Rather than just showing the absolute price, it focuses on the "range"—the distance between the highest and lowest points reached during a specific period of time.

Core Functionality

The logic operates by analyzing the difference between the high and low prices of the most recent candle and comparing it directly to the high and low values of the candle immediately preceding it. It then categorizes every candle into one of three distinct states based on this comparison:

  • Higher Range: This is triggered when the current price movement is larger than the previous candle's movement. The script identifies this as an expansion in volatility.
  • Lower Range: This occurs when the current price movement is smaller than the previous candle's movement, indicating a contraction or cooling off in market activity.
  • No Change: This state is triggered if the distance between the high and low remains exactly the same as the previous period, signaling a neutral trend in volatility.

Visual Representation

The tool presents this data in a dedicated window separate from the main price chart, using a color-coded histogram format to make trends easily identifiable:

  • Green highlights instances where the range is increasing.
  • FireBrick (Red) highlights instances where the range is decreasing.
  • Black denotes periods where the range remains unchanged.

Real-Time Data Display

In addition to the histogram, the script provides a dynamic text overlay on the chart. It continuously calculates the exact numerical value of the current candle's range and displays it as a text label. This allows traders to see the specific magnitude of price movement in real-time, providing a clear numerical confirmation of the volatility trends displayed in the histogram.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Range_v3
//+------------------------------------------------------------------+
//|                                                      Range V1.0  |
//|                                                                  |
//|              Copyright © 2005, Jason Robinson                    |
//|               (jasonrobinsonuk,  jnrtrading)                     |
//|                http://www.jnrtrading.co.uk                       |
//|                                                                  |
//|               THIS VERSION IS FROM MY WEBSITE                    |
//|         (unless it has been posted by me on a forum)             |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Jason Robinson"
#property link      "http://www.jnrtrading.co.uk"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 FireBrick
#property indicator_color3 Black
#property indicator_minimum 0

double higher[];
double lower[];
double noChange[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0, higher);
   SetIndexLabel(0, "Higher");
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1, lower);
   SetIndexLabel(1, "Lower");
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2, noChange);
   SetIndexLabel(2, "No Change");
   IndicatorShortName("Range (H L nC)");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit, i;
   int counted_bars=IndicatorCounted();
//---- 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;

   for(i=0; i<=limit; i++)
     {
      if (High[i] - Low[i] > High[i+1] - Low[i+1])
        {
         higher[i]=High[i] - Low[i];
         lower[i]=0;
         noChange[i]=0;
        }
      else
         if (High[i] - Low[i] < High[i+1] - Low[i+1])
           {
            lower[i]=High[i] - Low[i];
            higher[i]=0;
            noChange[i]=0;
           }
         else
           {
            noChange[i]=High[i] - Low[i];
            lower[i]=0;
            higher[i]=0;
           }
      //----
      ObjectDelete("Range");
      ObjectCreate("Range", OBJ_TEXT, 1, Time[0], High[0] - Low[0]);
      ObjectSetText("Range", "             " + DoubleToStr(High[0] - Low[0], 4), 10, "Verdana", Black);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments