sortvolume
Download scriptThis tool is designed to provide a more granular look at trading volume for currency pairs. In standard trading charts, "volume" often simply tells you how much activity occurred during a specific time period. This script takes that data a step further by breaking down that volume into the individual components that make up the pair.
How it Works
Every currency pair consists of two different assets (for example, in EUR/USD, the "Euro" is one side and the "US Dollar" is the other). Typically, standard trading platforms do not show you how much of each specific currency was traded independently; they only show the total volume for the transaction as a whole.
This script changes that by performing a mathematical distribution of the volume based on price action:
- Volume Distribution: The logic analyzes the "High," "Low," "Open," and "Close" prices of every individual candle on your chart.
- Proportional Calculation: It calculates how much of the total movement occurred on one side versus the other. It determines the proportion of the price range covered by the opening and closing prices relative to the high and low points of that period.
- Visual Representation: Instead of showing a single volume bar, it splits the data into two distinct visual components (represented as blue and red histograms). One color represents the volume attributed to the first currency in the pair, while the other represents the second.
Key Benefits for Traders
By using this logic, you can gain a clearer understanding of the "tug-of-war" between two currencies. Rather than seeing just a large spike in general activity, you can visualize which side of the pair is driving the most significant weight behind the price movement at any given moment. This allows for a more nuanced interpretation of market sentiment and liquidity flow within a single currency pair.
//+------------------------------------------------------------------+
//| r_Volume |
//| Copyright 2015, riolious |
//| riolious@outlook.com |
//+------------------------------------------------------------------+
#property copyright "Coded by riolious"
#property link "riolious@outlook.com"
#property version "2.0"
#property description "Calculates volume each currency on pair."
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 2
double xVol[],yVol[];
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
IndicatorDigits(0);
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,clrBlue);
SetIndexBuffer(0,xVol);
SetIndexLabel(0,StringSubstr(Symbol(),0,3));
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,clrRed);
SetIndexBuffer(1,yVol);
SetIndexLabel(1,StringSubstr(Symbol(),3,3));
IndicatorShortName("Sort Volume");
return(0);
}
//+------------------------------------------------------------------+
//| Deitialization |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Start r_Volume |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars-1;
for(int i=limit;i>=0;i--)
{
double PipBar=(MathMax(Open[i],Close[i])-MathMin(Open[i],Close[i]))*MathPow(10,Digits);
double VolumePerPip=0;
xVol[i]=0;
yVol[i]=0;
if(High[i]!=Low[i])
{
VolumePerPip=Volume[i]/((High[i]-Low[i])*MathPow(10,Digits));
if(Open[i]==Close[i])
{
xVol[i]=((Close[i]-Low[i])*MathPow(10,Digits))*VolumePerPip;
yVol[i]=((High[i]-Close[i])*MathPow(10,Digits))*VolumePerPip;
}
else
{
if(Open[i]<Close[i])
{
xVol[i]=PipBar*VolumePerPip;
yVol[i]=((High[i]-Close[i])*MathPow(10,Digits))*VolumePerPip;
}
if(Open[i]>Close[i])
{
xVol[i]=((Close[i]-Low[i])*MathPow(10,Digits))*VolumePerPip;
yVol[i]=PipBar*VolumePerPip;
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments