CHO
Download scriptThis tool is a custom technical analysis indicator designed to help traders visualize market momentum and volume trends on a separate pane of the trading chart. It operates by analyzing the relationship between price movement and trading volume, specifically focusing on how "aggressive" the buying or selling pressure is over different periods of time.
How the Logic Works
The script functions in three primary stages to generate its visual output:
1. Volume Analysis (Accumulation Distribution) First, the tool gathers data on the "Accumulation Distribution" (AD). This is a core metric that looks at where the price closes relative to its range and multiplies it by the volume of the trade. Essentially, it helps identify whether the money flowing into an asset is actually moving the price in a sustainable direction or if it is merely temporary volatility.
2. Smoothing the Data To filter out "market noise" (random, insignificant price fluctuations), the script applies a smoothing technique to the volume data. Users can choose between two different methods:
- Simple Moving Average (SMA): This takes a straightforward average of recent data points.
- Exponential Moving Average (EMA): This gives more weight to the most recent data, making the indicator slightly more responsive to sudden changes in market behavior.
3. Calculating the Oscillator The final visual result—the "Chaikin Oscillator"—is created by comparing two different smoothed averages of the volume data:
- A Fast Period (representing short-term momentum).
- A Slow Period (representing long-term momentum).
By subtracting the slow average from the fast average, the tool creates a line that moves above and below a zero point.
What this means for the user
When the line on the chart trends upward, it suggests that short-term buying/selling pressure is accelerating faster than the long-term trend. Conversely, a downward trend suggests that momentum is slowing down or reversing. This helps traders identify potential turning points in the market by highlighting discrepancies between price action and actual volume flow.
//+------------------------------------------------------------------+
//| CHO.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DarkBlue
//---- input parameters
extern int SlowPeriod=10;
extern int FastPeriod=3;
extern int TypeSmooth=0;// 0 - SMA, 1 - EMA
//---- buffers
double CHO[];
double AD[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
string name,smoothString;
if (TypeSmooth<0 || TypeSmooth>1) TypeSmooth=0;
if (TypeSmooth==0) smoothString="SMA"; else smoothString="EMA";
name="Chaikin Oscillator("+SlowPeriod+","+FastPeriod+","+smoothString+")";
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,CHO);
SetIndexLabel(0,name);
SetIndexEmptyValue(0,0.0);
SetIndexBuffer(1,AD);
SetIndexEmptyValue(1,0.0);
IndicatorShortName(name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
//----
if (counted_bars<0) return(-1);
if (counted_bars==0)
{
limit=Bars-1;
for (i=limit;i>=0;i--)
{
AD[i]=iAD(NULL,0,i);
}
for(i=limit-SlowPeriod;i>=0;i--)
{
CHO[i]=iMAOnArray(AD,0,FastPeriod,0,TypeSmooth,i)-iMAOnArray(AD,0,SlowPeriod,0,TypeSmooth,i);
}
}
if (counted_bars>0)
{
limit=Bars-counted_bars;
for (i=limit;i>=0;i--)
{
AD[i]=iAD(NULL,0,i);
}
for(i=limit;i>=0;i--)
{
CHO[i]=iMAOnArray(AD,0,FastPeriod,0,TypeSmooth,i)-iMAOnArray(AD,0,SlowPeriod,0,TypeSmooth,i);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments