AMA & AMA sig_001

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

This tool is a specialized technical analysis indicator designed to help traders identify trends and potential entry points in the financial markets. It works by processing price data to create a smoothed trend line, while simultaneously filtering out market "noise" to provide clearer visual signals.

How the Logic Works

1. Trend Smoothing (The AMA Line) At its core, the script calculates an Adaptive Moving Average (AMA). Unlike standard moving averages that treat all price movements equally, this logic adjusts itself based on current market conditions. It evaluates the "noise" level of the market by comparing recent price fluctuations against a specific timeframe.

  • In low-volatility markets: The indicator focuses on capturing the underlying trend more smoothly.
  • In high-volatility markets: It reacts more dynamically to ensure it doesn't lag too far behind the actual price action.

2. Signal Detection (The Arrows) Beyond simply drawing a line, the script looks for specific "breakout" behaviors to generate visual signals on your chart:

  • Upward Signals: The script monitors the distance between the calculated moving average and its previous value. If the average moves upward by a specific threshold (defined by the user's sensitivity settings), it marks an upward signal.
  • Downward Signals: Conversely, if the moving average drops below a specific threshold in a downward direction, it marks a downward signal.

3. Customizable Sensitivity The logic allows for several "knobs" to be turned to suit different trading styles:

  • Period Settings: You can define how many past candles the script looks at to determine the trend and the noise level.
  • Fast/Slow Factors: These balance the speed of the indicator, determining how quickly it reacts to new price data versus how much it ignores minor fluctuations.
  • Signal Threshold: You can set a specific "distance" (the dK factor) that the price must move before an arrow is displayed, helping to filter out tiny movements that aren't significant enough to trade.

Summary for the Trader

In plain terms, this script acts as a smart filter. It draws a line that follows the price but "softens" the jagged edges of constant market noise. When that line makes a significant enough turn upward or downward, it prints an arrow on your chart, notifying you of a potential change in momentum.

Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
AMA & AMA sig_001
//+------------------------------------------------------------------+
//|                                                   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