Accumulation2MA_v03
Download scriptThis tool is designed to help traders visualize the relationship between price movement and trading volume by analyzing "Accumulation and Distribution." In simpler terms, it looks at how much money or "effort" is moving into or out of a market to help identify the underlying strength of a trend.
How the Logic Works
1. Measuring Market Effort (The Foundation) The script first looks at three core price points for every candle: the High, the Low, and the Close. It calculates where the price finished relative to its total range for that period. If the price closed near the high of the day, it suggests buying pressure; if it closed near the low, it suggests selling pressure.
2. Factoring in Volume Price movement alone can sometimes be misleading. To get a more accurate picture, the script multiplies that price position by the actual trading volume. This tells the tool not just where the price went, but how much activity occurred to get it there.
3. Creating a Running Total (Cumulative Flow) Instead of looking at each candle in isolation, the script adds the current result to all the previous results. This creates a "running total" or a cumulative flow. Think of this like a bank balance: rather than just seeing how much money you spent today, it shows your total balance over time based on every transaction ever made.
4. The Signal Mechanism (Moving Averages) To make this data readable and smooth out the "noise," the script applies two different moving averages to that cumulative flow:
- A Fast Average: Reacts quickly to recent changes in volume and price.
- A Slow Average: Provides a broader, steadier view of the long-term trend.
5. The Final Output The indicator calculates the distance between these two averages (the Fast and the Slow). By subtracting the slow value from the fast value and magnifying the result, it produces a visual line on your chart.
What This Means for the Trader
When the resulting line moves significantly in one direction, it indicates that the momentum of accumulation is shifting. It helps identify whether the current price trend is being supported by heavy volume (strong conviction) or if it is losing steam, potentially signaling an upcoming change in market direction.
//+------------------------------------------------------------------+
//| 2MA from A/D Accumulation2MA.mq4 |
//| Copyright © 2006, lukas1 |
//| http://www.alpari-idc.ru/ |
//| v.03
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, lukas1"
#property link "http://www.alpari-idc.ru/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
//---- buffers
extern int FMA=3;
extern int SMA=10;
double ExtMapBuffer1[];
double SignalBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Difference 2MA fast="+FMA+", slow="+SMA+" from A/D");
//---- indicators
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,0,2);
SetIndexBuffer(1,SignalBuffer1);
//----
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_SMA,i)*20
-iMAOnArray(ExtMapBuffer1,Bars,SMA,0,MODE_SMA,i)*20;
//----
return(0);
}
//+------------------------------------------------------------------+
Comments