Author: Copyright � 2008, LEGRUPO
BarRange3

This tool is designed to provide traders with a clear, visual representation of the price volatility occurring within specific timeframes on a trading chart. By analyzing the "range" of each individual candle, it helps users quickly identify how much price movement occurred from the highest point to the lowest point during a given period.

Core Functionality

The script automatically calculates the difference between the high and low prices for every candle displayed on your chart. Instead of making you do the math manually, it extracts this data and converts it into a readable numerical value. To ensure these numbers are easy to interpret regardless of the currency or asset being traded, the tool automatically scales the result into a standardized format (pips/points) based on the decimal precision of your specific chart.

Visual Presentation

The primary goal of this script is visual clarity. Rather than cluttering the screen with complex lines or graphs, it performs the following actions:

  • Dynamic Labeling: It places a text label directly beneath the candles on your chart.
  • Real-Time Updates: As new price data comes in, the tool updates these labels to reflect the most recent price action.
  • Customizable Visibility: You can control how far back the data is displayed. By adjusting the settings, you can choose to see the range for only the most recent candle or a larger historical period.
  • Color-Coded Readability: The values are presented in a clear, green font, making it easy to distinguish the price movement data from other chart elements like moving averages or trend lines.

Practical Application

For a trader, this logic serves as a quick reference for "exhaustion" or "momentum." By looking at the labels provided by the script, you can instantly see if the current candle is moving significantly more than previous ones, helping you gauge market volatility at a glance without having to manually subtract price points.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
BarRange3
//+------------------------------------------------------------------+
//|                                                  Daily Range.mq4 |
//|                                        Copyright © 2008, LEGRUPO |
//|                                           http://www.legrupo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, LEGRUPO"
#property link      "http://www.legrupo.com"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int disp_bar = 1;

double BufferRange[];
   string PatternText[5000];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//   IndicatorBuffers(1);
   SetIndexStyle(0, DRAW_ARROW, 0, 1);
   SetIndexArrow(0, 172);
   SetIndexBuffer(0,BufferRange);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   double bar_range;
//----
   if (counted_bars < 0) {
      return(-1);
   }
   
   if (counted_bars > 0) {
      counted_bars--;
   }
   int pos = Bars-counted_bars;
//   string PatternText[5000];
    for(int j = 0; j < Bars; j++) 
     { 
       PatternText[j] = "pattern-" + j;
     }
     
   while (pos>=0) {
      bar_range = (High[pos] - Low[pos]);
      if (Digits < 4) bar_range = bar_range * 100; else bar_range = bar_range * 10000;

      if(pos<=disp_bar - 1){
      ObjectDelete(PatternText[pos]);
      ObjectCreate(PatternText[pos], OBJ_TEXT, 0, Time[pos], Low[pos]);
      ObjectSet(PatternText[pos], OBJPROP_YDISTANCE, 200);
      ObjectSetText(PatternText[pos], DoubleToStr(bar_range, 0), 10, "Verdana", Green);
      
      BufferRange[pos] = bar_range;
      }
      pos--;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments