AMA & AMA sig

Download script
Author: Copyright � 2004, by GOODMAN & Mstera � AF
AMA & AMA sig

This tool is designed to analyze financial market price movements by creating a smoothed trend line and identifying specific entry signals based on the momentum of that trend. Instead of simply following price directly, it uses a sophisticated mathematical approach to filter out "market noise" and highlight significant shifts in direction.

Core Logic and Mechanics

1. Noise Reduction and Trend Smoothing The primary goal of this script is to calculate an Average Moving Average (AMA). Unlike standard moving averages that can be jumpy or lag significantly behind price, this logic calculates the "noise" level of the market by measuring the volatility over a specific period. By comparing the current price movement against this calculated noise, the script determines how much weight to give to new price data. If the market is volatile (high noise), the indicator stays smoother; if the market is moving steadily, it adapts more quickly.

2. Dynamic Weighting System The script utilizes two different speeds—a "fast" and a "slow" component. It calculates the relationship between these two speeds to create a dynamic coefficient. This ensures that the resulting trend line reacts fluidly to price changes without creating false signals caused by minor, insignificant price fluctuations.

3. Momentum Detection Once the smoothed trend line is established, the script looks for specific "breaks" or movements in that line. It measures the distance between the current value of the trend and its previous value.

Visual Indicators

The script provides three distinct visual outputs on your chart:

  • The Trend Line: A continuous line (Sienna) that represents the calculated Average Moving Average. This helps you see the primary direction of the market at a glance.
  • Bullish Signals (Upward): When the trend line moves upward by a specific minimum distance (defined by the sensitivity settings), the script places a gold arrow on the chart. This indicates a potentially strong upward momentum.
  • Bearish Signals (Downward): Conversely, when the trend line moves downward by that same minimum distance, a blue arrow is placed on the chart, signaling potential downward momentum.

Summary for the User

In plain terms, this tool filters out the "jitter" of the market to show you a clean path of where the price is heading. Rather than alerting you to every small move, it only triggers a visual signal (an arrow) when the trend moves with enough strength and conviction to overcome the surrounding market noise.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
AMA & AMA sig
//+------------------------------------------------------------------+
//|                                                   AMA&AMAsig.mq4 |                                                             
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by GOODMAN & Mstera è AF "
      
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Sienna
#property indicator_color2 DeepSkyBlue
#property indicator_color3 Gold

//---- input parameters
extern int       periodAMA=9;
extern int       nfast=2;
extern int       nslow=30;
extern double    G=2.0;
extern double    dK=2.0; 

//---- buffers
double kAMAbuffer[];
double kAMAupsig[];
double kAMAdownsig[];

//+------------------------------------------------------------------+

int    cbars=0, prevbars=0, prevtime=0;

double slowSC,fastSC;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,159);
   //SetIndexDrawBegin(0,nslow+nfast);
   SetIndexBuffer(0,kAMAbuffer);
   SetIndexBuffer(1,kAMAupsig);
   SetIndexBuffer(2,kAMAdownsig);
   
   
   IndicatorDigits(4);
   
   //slowSC=0.064516;
   //fastSC=0.2;
   //cbars=IndicatorCounted();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,pos=0;
   double noise=0.000000001,AMA,AMA0,signal,ER;
   double dSC,ERSC,SSC,ddK;
   
   if (prevbars==Bars) return(0);
    
//---- TODO: add your code here
   slowSC=(2.0 /(nslow+1));
   fastSC=(2.0 /(nfast+1));
   cbars=IndicatorCounted();
   if (Bars<=(periodAMA+2)) return(0);
//---- check for possible errors
   if (cbars<0) return(-1);
//---- last counted bar will be recounted
   if (cbars>0) cbars--;
   pos=Bars-periodAMA-2;
   AMA0=Close[pos+1];
   while (pos>=0)
     {
      if(pos==Bars-periodAMA-2) AMA0=Close[pos+1];
      signal=MathAbs(Close[pos]-Close[pos+periodAMA]);
      noise=0.000000001;
      for(i=0;i<periodAMA;i++)
       {
        noise=noise+MathAbs(Close[pos+i]-Close[pos+i+1]);
       };
      ER =signal/noise;
      dSC=(fastSC-slowSC);
      ERSC=ER*dSC;
      SSC=ERSC+slowSC;
      AMA=AMA0+(MathPow(SSC,G)*(Close[pos]-AMA0));
      kAMAbuffer[pos]=AMA;

      ddK=(AMA-AMA0);
      if ((MathAbs(ddK)) > (dK*Point) && (ddK > 0)) kAMAupsig[pos] =AMA; else kAMAupsig[pos]=0;
      if ((MathAbs(ddK)) > (dK*Point) && (ddK < 0)) kAMAdownsig[pos]=AMA; else kAMAdownsig[pos]=0; 

     
      AMA0=AMA;
      pos--;
     };
//----
   prevbars=Bars;
   return(0);
  }

Comments