Author: Copyright � 2008, LEGRUPO
BarRange

This tool is designed to provide traders with a clear, visual representation of price volatility by calculating and displaying the "Daily Range" for every candle on your trading chart. Instead of requiring you to manually calculate the distance between the highest and lowest prices, the script automates this process and highlights it directly on your screen.

How it Works

The logic follows a straightforward three-step process to ensure you have an immediate understanding of market movement:

  • Volatility Calculation: The script scans each individual candle (bar) on your chart. It identifies the highest price point reached (High) and the lowest price point reached (Low) during that specific timeframe. By subtracting the low from the high, it determines the exact size of the price movement for that period.
  • Visual Labeling: Once the range is calculated, the script places a text label directly beneath each candle. This allows you to see at a glance how much "room" the price moved. The labels are formatted clearly in a standard font so they remain legible as you scroll through different historical periods.
  • Dynamic Data Display: The numerical value of the range is converted into a readable decimal format that matches your specific currency or asset's digits. This means whether you are trading Forex, Stocks, or Commodities, the data displayed will be accurate to your specific market's requirements.

Key Benefits for Traders

  • Instant Volatility Assessment: You can quickly identify periods of high activity versus "quiet" markets without doing any manual math.
  • Visual Consistency: By placing the range data directly on the chart, the information remains tied to the price action, making it easier to recognize patterns in market behavior over time.
  • Automated Organization: The script automatically manages the creation and placement of these labels, ensuring that your chart remains organized and that every historical bar is accounted for.
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
BarRange
//+------------------------------------------------------------------+
//|                                                  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

double BufferRange[];
//+------------------------------------------------------------------+
//| 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();
//----
   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) {
      double bar_range = (High[pos] - Low[pos]);
      ObjectCreate(PatternText[pos], OBJ_TEXT, 0, Time[pos], Low[pos]);
      ObjectSet(PatternText[pos], OBJPROP_YDISTANCE, 200);
      ObjectSetText(PatternText[pos], DoubleToStr(bar_range, Digits), 10, "Verdana", White);
      
      BufferRange[pos] = bar_range;
      pos--;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments