Accumulation_v2
Download scriptThis tool is designed to help traders visualize the underlying flow of money and market momentum by analyzing price movement in relation to trading volume. Rather than looking at price alone, it attempts to measure how much "accumulation" (buying pressure) or "distribution" (selling pressure) is occurring behind the scenes.
How the Logic Works
1. Calculating Market Pressure The core logic begins by looking at the range of a single price candle—specifically, where the price closed relative to its highest and lowest points.
- If a price closes near the top of its range, the tool interprets this as significant buying pressure.
- If it closes near the bottom, it suggests selling pressure. By measuring these positions and comparing them against the total volume traded during that period, the script calculates a relative strength value for every candle.
2. Cumulative Tracking Unlike many indicators that only show what happened in the current moment, this script is "cumulative." It adds the current candle's pressure value to the sum of all previous values. This creates a running total, allowing you to see the ongoing buildup or depletion of market energy over time.
3. Smoothing and Trend Analysis To make the data easier for a human to read, the script applies two different types of mathematical smoothing (Moving Averages) to that cumulative total:
- Fast Response: One line reacts quickly to changes in price and volume, helping to identify immediate shifts in momentum.
- Slow Response: A second line provides a broader view of the trend, filtering out minor market "noise."
How to Interpret the Results
The primary purpose of this logic is to identify discrepancies between price action and volume. By observing the relationship between the fast-moving line and the slower-moving line, traders can look for:
- Trend Confirmation: When both lines move in synchronization, it confirms the strength of the current trend.
- Potential Reversals: If the price is moving in one direction but the cumulative volume lines begin to flatten or diverge, it may suggest that the momentum is weakening and a trend reversal could be approaching.
//+------------------------------------------------------------------+
//| Accumulation&2MA.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| only modified by lukas1 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes + lukas1"
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
#property indicator_color3 Blue
//---- buffers
extern int FMA=3;
extern int SMA=10;
double ExtMapBuffer1[];
double SignalBuffer1[];
double SignalBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("A/D");
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,0,2);
SetIndexBuffer(1,SignalBuffer1);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(2,SignalBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
int i,limit,counted_bars=IndicatorCounted();
limit=(Bars-counted_bars);
//----
i=Bars-counted_bars-1;
while(i>=0)
{
double high =High[i];
double low =Low[i];
double open =Open[i];
double close=Close[i];
ExtMapBuffer1[i]=(close-low)-(high-close);//2close+high-low
if(ExtMapBuffer1[i]!=0)
{
double diff=high-low;
if(0==diff)
ExtMapBuffer1[i]=0;
else
{
ExtMapBuffer1[i]/=diff;
ExtMapBuffer1[i]*=Volume[i];
}
}
if(i<Bars-1) ExtMapBuffer1[i]+=ExtMapBuffer1[i+1];
i--;
}
for(i=0; i<limit; i++)
SignalBuffer1[i]=iMAOnArray(ExtMapBuffer1,Bars,FMA,0,MODE_EMA,i);
for(i=0; i<limit; i++)
SignalBuffer2[i]=iMAOnArray(ExtMapBuffer1,Bars,SMA,0,MODE_EMA,i);
//----
return(0);
}
//+------------------------------------------------------------------+
Comments