_TRO_RANGE_v1

_TRO_RANGE_v1

Overview of the Range Indicator

This tool is designed to help traders visualize and monitor price volatility by measuring the "range" of price movement within specific time periods. Rather than looking at complex mathematical trends, this script focuses on a straightforward metric: how much distance was covered between the highest and lowest points during a single candle (bar).

How it Works

The core logic of the script revolves around calculating the difference between the high and low price for every bar on your chart. It then categorizes these movements based on a specific intensity level, which you can define as a "Threshold."

1. Range Measurement For every candle on the chart, the script calculates the total distance traveled from the top (High) to the bottom (Low). This measurement is converted into "points" to ensure consistency across different types of assets.

2. Volatility Categorization The tool separates these measurements into two distinct visual categories based on your chosen threshold:

  • Standard Range: If the movement between the high and low is smaller than your set threshold, it is recorded in one category.
  • Extended Range: If the price movement exceeds your threshold, the script flags it as a larger move and records it in a separate category.

This allows you to easily distinguish between "normal" market activity and periods of significant volatility or rapid price spikes.

3. Visual Presentation The indicator operates in its own dedicated sub-window (separate from the main price chart) to keep your workspace clean. It displays these measurements as a histogram:

  • Color Coding: The script uses two different colors to visually separate standard movements from those that break your threshold, making it easy to spot high-activity zones at a glance.
  • Live Tracking: The tool also provides real-time visual markers. It continuously updates a horizontal line and a text label to show you the exact range value of the current, active candle as it develops.

Key Features for the User

  • Customizable Threshold: You can easily adjust what qualifies as a "large" move by changing the threshold value in the settings.
  • Visual Clarity: By separating high-volatility moves from standard ones, the indicator helps you identify where the market is reacting most aggressively.
  • Real-Time Monitoring: The live tracking feature ensures you are always aware of the price spread of the current candle in real-time.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
_TRO_RANGE_v1
//+-------------------------------------------------------------------+ 
//|                                        _TRO_RANGE.mq4             | 
//|                                                         TRO, 2007 | 
//|                                modified by Skyline on 22 Nov 2007 | 
//+-------------------------------------------------------------------+ 
#property  copyright "Copyright ? 2007, Avery T. Horton, Jr. aka TRO"
#property  link      "http://www.therumpldone.com/"
//---- indicator settings 
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Green
//---- indicator buffers 
double     RANGEBuffer[];
double     RANGEBuffer1[];
//---- indicator parameters  
extern int   Threshold=20;
extern color CurrentBarColor=White;
extern color ThresholdColor =Aqua;
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init()
  {
//---- drawing settings 
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
//---- indicator buffers mapping 
   SetIndexBuffer(0,RANGEBuffer);
   SetIndexBuffer(1,RANGEBuffer1);
//---- name for DataWindow and indicator subwindow label 
   IndicatorShortName("RANGE");
   SetIndexLabel(0,"RANGE");
   SetIndexLabel(1,"RANGE");
//---- initialization done 
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("CurrentBarValue");
   ObjectDelete("LabelCurrentBarValue");
  }
//+------------------------------------------------------------------+ 
//| Range                                                            | 
//+------------------------------------------------------------------+ 
int start()
  {
   double HighVal,LowVal;
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted 
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- RANGE counted in the 1-st buffer 
   for(int i=0; i<limit; i++)
     {
      HighVal =iHigh(NULL,0,i);
      LowVal  =iLow(NULL,0,i);
      if ((HighVal-LowVal)/Point>=Threshold) { RANGEBuffer1[i]=(HighVal-LowVal)/Point; }
      else { RANGEBuffer[i]=(HighVal-LowVal)/Point; }
      // Draw Threshold line 
      int win_idx=WindowFind("RANGE");
/*
     ObjectDelete("Threshold"); 
     ObjectCreate("Threshold", OBJ_HLINE, win_idx, Time[0], Threshold); 
     ObjectSet("Threshold", OBJPROP_COLOR, ThresholdColor); 
     ObjectSet("Threshold", OBJPROP_STYLE, STYLE_SOLID); 
     ObjectSet("Threshold", OBJPROP_WIDTH, 1); 
     ObjectSet("Threshold", OBJPROP_BACK, true);   
      Label for Threshold 
     ObjectDelete("LabelThreshold"); 
     ObjectCreate("LabelThreshold", OBJ_TEXT, win_idx, Time[0], Threshold); 
     ObjectSet("LabelThreshold", OBJPROP_COLOR, ThresholdColor); 
     ObjectSetText("LabelThreshold", "Threshold",8); 
     ObjectSet("LabelThreshold", OBJPROP_ANGLE, 0); 
*/
      // Draw Current Bar line value 
      ObjectDelete("CurrentBarValue");
      ObjectCreate("CurrentBarValue", OBJ_HLINE, win_idx, Time[0], (iHigh(NULL,0,0)-iLow(NULL,0,0))/Point);
      ObjectSet("CurrentBarValue", OBJPROP_COLOR, CurrentBarColor);
      ObjectSet("CurrentBarValue", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("CurrentBarValue", OBJPROP_WIDTH, 1);
      ObjectSet("CurrentBarValue", OBJPROP_BACK, true);
      // Label per Current Bar Line 
      // ObjectDelete("LabelCurrentBarValue"); 
      // ObjectCreate("LabelCurrentBarValue", OBJ_TEXT, win_idx, Time[0], (iHigh(NULL,0,0)-iLow(NULL,0,0))/Point); 
      ObjectSet("LabelCurrentBarValue", OBJPROP_COLOR, CurrentBarColor);
      ObjectSetText("LabelCurrentBarValue", "Current Bar value",8);
      ObjectSet("LabelCurrentBarValue", OBJPROP_ANGLE, 0);
     }
//---- done 
   return(0);
  }
//------------------------------------------------------------------+

Comments