Accelerator_v2

Download script
Accelerator_v2

The Accelerator/Decelerator Oscillator is a technical analysis tool designed to help traders understand the underlying momentum and "health" of a market trend. Rather than just looking at price movements, this script analyzes the relationship between different types of moving averages to determine if a trend is gaining strength or losing steam.

How the Logic Works

The script operates through a multi-layered calculation process:

1. Baseline Momentum Calculation First, the tool calculates two distinct moving averages based on the midpoint of the price. By subtracting one average (a shorter period) from another (a longer period), it creates a "momentum" value. This helps identify whether the price is moving faster than its historical average.

2. Signal Smoothing The script then takes that momentum value and applies a secondary smoothing layer. This acts as a "signal line," filtering out minor market noise to reveal the broader trend of the momentum itself.

3. The Accelerator & Decelerator Logic The core intelligence of the script lies in comparing the current state of momentum against its previous values. It calculates the difference between the primary momentum and the signal line:

  • Strength Tracking: By comparing these differences across consecutive bars, the tool determines whether the "acceleration" is increasing or decreasing.
  • Visual Differentiation: The logic automatically categorizes these movements. It distinguishes between upward-moving energy and downward-moving energy, assigning them to different visual profiles.

What This Means for the Trader

Instead of a cluttered chart, this script simplifies complex data into a clear histogram. It allows you to see:

  • Trend Persistence: Whether a current move is being "accelerated" by strong buying/selling pressure or if it is beginning to "decelerate" (lose power).
  • Trend Reversals: By observing when the momentum shifts from one state to another, traders can potentially identify points where a trend might be exhausting itself before a price reversal occurs.

In essence, this tool acts as a speedometer for market trends, telling you not just which way the "car" is moving, but how hard it is pressing on the gas pedal or lifting its foot off the brake.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Accelerator_v2
//+------------------------------------------------------------------+
//|                                                  Accelerator.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Green
#property  indicator_color3  Red
//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
double     ExtBuffer3[];
double     ExtBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+2);
   SetIndexDrawBegin(0,38);
   SetIndexDrawBegin(1,38);
   SetIndexDrawBegin(2,38);
//---- 4 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(3,ExtBuffer3);
   SetIndexBuffer(4,ExtBuffer4);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AC");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   //---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      ExtBuffer3[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
   //---- signal line counted in the 2-nd additional buffer
   for(i=0; i<limit; i++)
      ExtBuffer4[i]=iMAOnArray(ExtBuffer3,Bars,5,0,MODE_SMA,i);
   //---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtBuffer3[i]-ExtBuffer4[i];
      prev=ExtBuffer3[i+1]-ExtBuffer4[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
       ExtBuffer0[i]=current;
     }
   //---- done
   return(0);
  }

Comments