sAccelerator

Download script
sAccelerator

This tool is designed as a visual and automated trading assistant that monitors market momentum by analyzing the relationship between different price averages. Instead of looking at raw price action, it focuses on how quickly the market is accelerating or decelerating to help identify potential trend reversals.

How the Logic Works

1. Momentum Calculation The script starts by calculating two distinct moving averages based on the median price. By subtracting a long-term average from a short-term average, it creates a base momentum value (similar to how a MACD indicator functions). It then takes this momentum and smooths it out once more to create a "signal line."

2. Visual Representation The tool displays these values in a separate window below your main price chart. It calculates the difference between the momentum value and its signal line to determine the current strength of the move:

  • Green Histograms: Represent upward movement or positive momentum.
  • Red Histograms: Represent downward movement or negative momentum.

3. Directional Tracking The script constantly compares the current difference between these two lines against the previous period. If the value is rising, it identifies an "up" trend; if it is falling, it identifies a "down" trend. This allows the indicator to stay synchronized with the active direction of the market flow.

Automated Alerts and Signals

Beyond just providing a visual graph, the script contains built-in logic to monitor specific price shifts at the close of each candle. It looks for a specific "hook" or confirmation pattern:

  • Buy Signal: The script monitors if the momentum has moved upward consecutively over three specific points in time. If this "acceleration" is confirmed, it triggers an automated alert on your screen.
  • Sell Signal: Conversely, if the script detects a consistent downward move across those same points, it triggers a sell alert.

Key Features for the User

  • Real-Time Alerts: You don't have to watch the charts constantly; the script will notify you via an alert popup when it detects a potential entry point based on its momentum calculations.
  • Clear Visualization: By separating the momentum into red and green histograms, it provides a quick at-a-glance view of whether the market is currently gaining speed or losing steam.
  • Filtered Data: The script is designed to avoid "false" signals by ensuring that alerts are only triggered once per bar, preventing your screen from being flooded with repetitive notifications during a single price movement.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
10 Views
0 Downloads
0 Favorites
sAccelerator
//+------------------------------------------------------------------+
//|                                                 sAccelerator.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[];
// Íîìåð áàðà, ïî êîòîðîìó áóäåò èñêàòüñÿ ñèãíàë
#define SIGNAL_BAR 1
//+------------------------------------------------------------------+
//| 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("sAC");
   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
//---- Ñòàòè÷åñêèå ïåðåìåííûå, â êîòîðûõ õðàíÿòñÿ
//---- âðåìÿ ïîñëåäíåãî áàðà è íàïðàâëåíèå ïîñëåäíåãî ñèãíàëà
	  static int PrevSignal = 0, PrevTime = 0;
//---- Åñëè áàðîì äëÿ àíàëèçà âûáðàí íå 0-é, íàì íåò ñìûñëà ïðîâåðÿòü ñèãíàë
//---- íåñêîëüêî ðàç. Åñëè íå íà÷àëñÿ íîâûé áàð, âûõîäèì.
	  if(SIGNAL_BAR > 0 && Time[0] <= PrevTime ) 
	      return(0);
//---- Îòìå÷àåì, ÷òî ýòîò áàð ïðîâåðåí
	  PrevTime = Time[0];
//---- Åñëè ïðåäûäóùèé ñèãíàë áûë ÑÅËË èëè ýòî ïåðâûé çàïóñê (PrevSignal=0)
	  if(PrevSignal <= 0)
	    {
		     if(ExtBuffer0[SIGNAL_BAR] - ExtBuffer0[SIGNAL_BAR+1] > 0 &&
				      ExtBuffer0[SIGNAL_BAR+2] - ExtBuffer0[SIGNAL_BAR+1] > 0 )
		       {
			        PrevSignal = 1;
			        Alert("sAC (", Symbol(), ", ", Period(), ")  -  BUY!!!");
		       }
	    }
	  if(PrevSignal >= 0)
	    {
		     if(ExtBuffer0[SIGNAL_BAR+1] - ExtBuffer0[SIGNAL_BAR] > 0 &&
				      ExtBuffer0[SIGNAL_BAR+1] - ExtBuffer0[SIGNAL_BAR+2] > 0)
		       {
			        PrevSignal = -1;
			        Alert("sAC (", Symbol(), ", ", Period(), ")  -  SELL!!!");
		       }
	    }
   return(0);
  }
//+------------------------------------------------------------------+

Comments