Author: Copyright � 2011, RJ Rjabkov Aleksandr
Rj_Volume

This tool is designed to provide a deeper look into how trading volume is actually distributed across different price levels. Rather than just showing you the total volume of a candle, this script breaks down that volume to reveal where the "action" is happening—specifically identifying where buyers and sellers are most active within a specific price range.

How it Works

The logic operates by analyzing price action over a user-defined period (defaulting to one day). It first establishes the boundaries of the market by finding the highest and lowest prices reached during that timeframe.

Once these boundaries are set, the script examines every individual one-minute candle within that period. For every candle, it performs the following calculation:

  • Identifying Price Movement: The script looks at the opening, closing, high, and low prices of each candle to determine the "momentum" of that specific price move.
  • Volume Distribution: It takes the total volume of that candle and distributes it proportionally based on how much of the move was driven upward versus downward.
  • Weighting Buyers vs. Sellers:
    • If a candle closed higher than it opened, the script calculates the portion of volume associated with the upward push (Buy Volume) and the portion associated with the downward resistance (Sell Volume).
    • If a candle closed lower than it opened, it reverses that logic to determine how much volume was driven by the downward move versus the upward pressure.

The Final Result

Instead of seeing a single volume bar at the bottom of your chart, this logic maps the cumulative "buying" and "selling" pressure onto specific price points. It essentially creates a profile of the market, allowing you to see:

  1. Price Density: Which price levels are being traded most heavily.
  2. Buy/Sell Pressure: At any given price level, it shows whether the prevailing sentiment was driven more by buyers or sellers.

By visualizing this data, traders can better understand where significant support and resistance might be forming based on actual volume concentration rather than just price movement alone.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
7 Views
0 Downloads
0 Favorites
Rj_Volume
//+------------------------------------------------------------------+
//|                                                    Rj_Volume.mq4 |
//|                           Copyright © 2011, RJ Rjabkov Aleksandr |
//|                                                     rj-a@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, RJ Rjabkov Aleksandr"
#property link      "rj-a@mail.ru"

#property indicator_chart_window
extern int DayRange = 1;

double VolBuy[];
double VolSell[];
static datetime LastTime;
int init() {
  IndicatorBuffers(2);
  SetIndexBuffer(0, VolBuy);
  SetIndexBuffer(1, VolSell);
  return(0);
}

int deinit() {return(0);}
 
int start() {
  int i, j;
  double MaxPrice = iHigh(NULL, PERIOD_D1, 0);
  double MinPrice = iLow(NULL, PERIOD_D1, 0);
  
  for(j=DayRange; j>=0; j--) {
    MaxPrice = MathMax(MaxPrice, iHigh(NULL, PERIOD_D1, j));
    MinPrice = MathMin(MinPrice, iLow(NULL, PERIOD_D1, j));
  }
  int Range = MathRound((MaxPrice-MinPrice)/Point);
    
  ArrayInitialize(VolBuy, 0.0);
  ArrayInitialize(VolSell, 0.0);
    
  for(i=iBarShift(NULL, PERIOD_M1, iTime(NULL, PERIOD_D1, DayRange)); i>=1; i--) {
  double lw=Low[i], op=Open[i], cl=Close[i], hg=High[i], vl=Volume[i];
  double up=0.0, sl=0.0, dl=0.0;  
    for(double k=High[i]; k>=Low[i]; k-=Point) {
      j = MathRound((k-MinPrice)/Point);

      if(op<cl) {
        up=((hg-lw)+(cl-op))/Point;
        sl=(hg-lw)/Point;
        if(up!=0 && sl!=0) {
          dl=vl/(up+sl);
          VolBuy[j]  += dl*up/sl;
          VolSell[j] += dl;
        }
      }
      if(op>=cl) {
        up=(hg-lw)/Point;
        sl=((hg-lw)+(op-cl))/Point;
        if(up!=0 && sl!=0) {
          dl=vl/(up+sl);
          VolBuy[j]  += dl;
          VolSell[j] += dl*sl/up;
        }
      }
    }
  }
  LastTime = TimeCurrent();
  return(0);
}
//+------------------------------------------------------------------+

Comments