Author: Andrey Matvievskiy
AO-AC(AM)

This technical tool is designed to analyze market momentum by examining the speed and strength of price movements. It functions by breaking down complex price action into two distinct layers of information: the core momentum (the "Accelerator") and the rate of change within that momentum (the "Decelerator").

Core Logic and Mechanism

The script operates through a multi-step calculation process to filter out market noise and highlight significant trend shifts:

1. The Foundation: Momentum Calculation The tool begins by comparing two different moving averages over specific time periods. By subtracting a long-term average from a short-term average, it establishes a baseline of current market momentum. This tells the user whether the price is generally trending upward or downward.

2. The Accelerator Layer The script then takes that base momentum and applies an additional smoothing process (the "Accelerator"). This acts as a secondary check to see how smoothly the momentum is moving. By comparing these two values, the tool can identify the "velocity" of the market.

3. Trend Visualization and Signal Generation The most unique aspect of this script is how it visually represents these dynamics. Rather than just showing a single line, it categorizes the data into four distinct visual components:

  • Acceleration Tracking (AC+ and AC-): These elements monitor the relationship between the momentum and its smoothed accelerator. They highlight whether the market is gaining "push" or losing steam. If the acceleration begins to drop even while the price is still moving in one direction, it can signal that the trend is weakening.
  • Oscillator Momentum (AO+ and AO-): These components represent the core momentum itself. They visually separate "upward strength" from "downward strength," allowing a trader to see the raw power of the current price movement.

Practical Application for Users

From a user's perspective, this script acts as a sophisticated "speedometer" for the market. Instead of just seeing that a price is going up, the logic allows you to see:

  • Strength: How forcefully the price is moving.
  • Sustainability: Whether the current move has enough "fuel" (acceleration) to continue or if it is starting to decelerate.
  • Directional Bias: By separating positive and negative momentum into different visual histograms, it makes it easier to identify exactly when a trend has exhausted itself and may be ready to reverse.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
AO-AC(AM)
//+------------------------------------------------------------------+
//|                                                    AO-AC(AM).mq4 |
//|                                               Andrey Matvievskiy |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Andrey Matvievskiy"
#property link      ""

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 7
#property  indicator_color1  Black
#property  indicator_color2  Black
#property  indicator_color3  Teal
#property  indicator_color4  Red
#property  indicator_color5  Teal
#property  indicator_color6  Red
#property  indicator_color7  Black

extern int AO_Period1 = 34;
extern int AO_Period2 = 5;
extern int AC_Period  = 5;

extern int AO_Mode1 = 0;
extern int AO_Mode2 = 0;
extern int AC_Mode  = 0;

extern int AO_Price1 = 4;
extern int AO_Price2 = 4;

extern int TF = 0;
//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
double     ExtBuffer3[];
double     ExtBuffer4[];
double     ExtBuffer5[];
double     ExtBuffer6[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(7);
//---- drawing settings
   
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,2);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,2);
   SetIndexStyle(4,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(5,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(6,DRAW_NONE);
   IndicatorDigits(Digits+2);
     
//---- 4 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(3,ExtBuffer3);
   SetIndexBuffer(4,ExtBuffer4);
   SetIndexBuffer(5,ExtBuffer5);
   SetIndexBuffer(6,ExtBuffer6);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AO_AC (AM) (TF "+TF+")");
   
   SetIndexLabel(0,NULL);
   SetIndexLabel(1,NULL);
   
   SetIndexLabel(2,"AC+");
   SetIndexLabel(3,"AC-");
   SetIndexLabel(4,"AO+");
   SetIndexLabel(5,"AO-");
   
   SetIndexLabel(6,NULL);
   SetIndexLabel(7,NULL);
  
//---- initialization done
   return(0);
  }

//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev1,current1,prev2,current2;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
      for(int i=0; i<limit; i++)
      ExtBuffer0[i]=iMA(NULL,TF,AO_Period2,0,AO_Mode2,AO_Price2,i)-iMA(NULL,TF,AO_Period1,0,AO_Mode1,AO_Price1,i);
      for(i=0; i<limit; i++)
      ExtBuffer1[i]=iMAOnArray(ExtBuffer0,Bars,AC_Period,0,AC_Mode,i);   
      bool up1=true;
      bool up2=true;
      for(i=limit-1; i>=0; i--)
     {
     
      current1=ExtBuffer0[i];
      prev1=ExtBuffer0[i+1];
      if(current1>prev1) up1=true;
      if(current1<prev1) up1=false;
      if(!up1)
        {
         ExtBuffer5[i]=current1;
         ExtBuffer4[i]=0.0;
        }
      else
        {
         ExtBuffer4[i]=current1;
         ExtBuffer5[i]=0.0;
        }
     
      current2=ExtBuffer0[i]-ExtBuffer1[i];
      prev2=ExtBuffer0[i+1]-ExtBuffer1[i+1];
      if(current2>prev2) up2=true;
      if(current2<prev2) up2=false;
      if(!up2)
        {
         ExtBuffer3[i]=current2;
         ExtBuffer2[i]=0.0;
        }
      else
        {
         ExtBuffer2[i]=current2;
         ExtBuffer3[i]=0.0;
        }
         ExtBuffer6[i]=current2;
     }    

   //---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments