accelerator_v4

Download script
accelerator_v4

The Accelerator Oscillator is a technical analysis tool designed to measure the momentum of price movements by comparing different speeds of market trends. Instead of looking at simple price action, this script focuses on the "acceleration" and "deceleration" of price changes to help traders identify potential shifts in market direction before they become obvious.

How the Logic Works

The script operates through a multi-layered calculation process to filter out market noise and highlight significant momentum:

1. Establishing the Base Momentum The tool begins by calculating two different types of moving averages based on price data. By subtracting one from the other, it creates a primary momentum value. Think of this as measuring the current speed of a vehicle; it tells us how fast the market is moving in a specific direction at this exact moment.

2. Identifying the Signal Trend To provide context to that "speed," the script takes the results of the first calculation and smooths them out further to create a secondary signal line. This represents the broader trend or the average speed over a slightly longer period. By comparing the immediate momentum against this smoothed signal, the tool can determine if the current move is gaining strength or beginning to exhaust.

3. Visualizing Directional Strength The final output is presented as a histogram in a separate window. The logic identifies whether the difference between the primary momentum and the signal line is increasing or decreasing:

  • Green Histograms: Represent periods where the momentum is actively rising, suggesting bullish strength.
  • Red Histograms: Represent periods where the momentum is falling, suggesting bearish pressure.

Summary for Traders

Essentially, this script acts as a "speedometer" for price action. By looking at the height and direction of the bars, you can see not just which way the market is going, but how aggressively it is moving there. When the bars begin to shrink or change color, it signals that the current move is losing its "acceleration," often serving as an early warning for a potential trend reversal or a period of consolidation.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
accelerator_v4
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                  Accelerator.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Green
#property  indicator_color2  Red
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];
double     ind_buffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(4);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
   SetIndexDrawBegin(0,38);
   SetIndexDrawBegin(1,38);
//---- 4 indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) &&
      !SetIndexBuffer(1,ind_buffer2) &&
      !SetIndexBuffer(2,ind_buffer3) &&
      !SetIndexBuffer(3,ind_buffer4))
      Print("cannot set indicators\' buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AC");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- 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++)
      ind_buffer3[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++)
      ind_buffer4[i]=iMAOnArray(ind_buffer3,Bars,5,0,MODE_SMA,i);
   //---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ind_buffer3[i]-ind_buffer4[i];
      prev=ind_buffer3[i+1]-ind_buffer4[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ind_buffer2[i]=current;
         ind_buffer1[i]=0.0;
        }
      else
        {
         ind_buffer1[i]=current;
         ind_buffer2[i]=0.0;
        }
     }
   //---- done
   return(0);
  }

Comments