AMASig

This tool is designed as a technical analysis indicator for the MetaTrader platform, primarily used to identify significant trends and momentum shifts in market price action. Rather than relying on simple moving averages, it utilizes a sophisticated mathematical approach known as the "Adaptive Moving Average" logic to filter out market volatility while highlighting meaningful price movements.

How the Logic Works

1. Volatility Filtering (Noise Analysis) The script begins by evaluating the "noise" of the market. It calculates the amount of variation in price movement over a specific period. By measuring the difference between consecutive opening prices, the tool establishes a baseline for how much the market is fluctuating naturally. This allows the indicator to distinguish between random price jitters and actual sustained movements.

2. Signal Strength Calculation The core logic compares current price positions against historical data points from a set look-back period. By calculating the ratio between the "Signal" (the total distance moved over that period) and the "Noise" (the volatility identified in step one), the script produces an Efficiency Ratio (ER).

  • If the market is moving efficiently with little noise, the ER is higher.
  • If the market is moving erratically with high noise, the ER is lower.

3. Adaptive Smoothing The indicator uses this Efficiency Ratio to adjust its responsiveness dynamically. In periods of strong, clear trends (high efficiency), the moving average reacts more quickly to the new price. During periods of choppy, sideways markets (low efficiency), the moving average becomes "steadier" and less reactive. This prevents the indicator from giving false signals during times of market confusion.

4. Trend Detection and Visual Alerts The final stage of the logic tracks the deviation between the current adaptive value and its previous state. The script is configured to trigger specific visual markers (arrows) on your chart when the price movement exceeds a predefined threshold:

  • Upward Signals: Triggered when the adaptive trend moves significantly upward beyond a certain point.
  • Downward Signals: Triggered when the adaptive trend moves significantly downward beyond a certain point.

Summary for Traders

Essentially, this script acts as a "smart" filter. It ignores the "messy" small movements of the market and only highlights significant directional shifts. By adapting its sensitivity based on current market volatility, it aims to provide clearer entry and exit cues by identifying when a trend has enough momentum to be considered meaningful.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
AMASig
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1  DodgerBlue
#property indicator_color2  Gold

//---- indicator parameters
extern int P = 400;
extern double fast = 2; 
extern double slow = 10;
extern double dK = 3;

//---- indicator buffers
double buf1[];
double buf2[];

double K1, K2;
double AMA, AMA0;
double Noise, Signal;
double ER, SSC;
int MyBars;

int init()
{  
   
//---- âû÷èñëÿåì ñãëàæèâàþùèå êîíñòàíòû
   K1 = 2/(1+slow);
   K2 = 2/(1+fast)-K1;
      
   Noise = 0;
   for(int j = Bars-2; j >= Bars-P-1; j--) {
      Noise += MathAbs(Open[j] - Open[j+1]);
/*
      abs[O[Bars-2] - O[Bars-1]]
      ...
      abs[O[Bars-P-1] - O[Bars-P]]
*/
   }
       
   AMA0 = Open[Bars-P-1];   
   MyBars = P+1;
   

   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 159);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 159);
   
      
   //IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1);

   SetIndexBuffer(0, buf1);
   SetIndexBuffer(1, buf2);
   SetIndexDrawBegin(0, P+1);
   SetIndexDrawBegin(1, P+1);
   
   IndicatorShortName("AMASig("+ P + ", " + fast + ", " + slow + ")");      
   return(0);
}
  
int start()
{ 
   if (MyBars >= Bars) return(0);
  
   for(int j = Bars-MyBars-1; j >= 0; j--) {
      Signal = MathAbs(Open[j] - Open[j+P]);            
/*
      abs(O[Bars-MyBars-1] - O[Bars-MyBars-1+P])    
      abs(O[Bars-P-2] - O[Bars-2])
      ...
      abs(O[0] - O[P])
*/
    
      Noise += MathAbs(Open[j] - Open[j+1]) - MathAbs(Open[j+P] - Open[j+P+1]);
/*
      abs(O[Bars-MyBars-1] - O[Bars-MyBars]) - abs(O[Bars-MyBars-1+P] - O[Bars-MyBars+P])
      abs(O[Bars-P-2] - O[Bars-P-1]) - abs(O[Bars-2] - O[Bars-1])
      ...
      abs(O[0] - O[1]) - abs(O[P] - O[P+1])
*/
  	  	   
   	if (Noise > 0) ER = Signal/Noise; else ER = 1;
   	//SSC = MathPow(K1+ER*K2, 2);
   	SSC = (K1+ER*K2)*(K1+ER*K2);
   	
      AMA = AMA0 + SSC*(Open[j]-AMA0);            
/*
      O[Bars-MyBars-1]
      O[Bars-P-2]
      ...
      O[0]
*/

      buf1[j] = -1;
      buf2[j] = -1;
      if (AMA-AMA0 > dK*Point) buf1[j] = AMA;
      if (AMA-AMA0 < -dK*Point) buf2[j] = AMA;

      AMA0 = AMA;
   }
     
   MyBars = Bars;
   return(0);
}

Comments