AMA & AMA sig_v1
Download scriptThe AMA&AMAsig tool is a sophisticated visual aid designed to help traders identify price trends and potential entry points by filtering out "market noise." Unlike standard moving averages that can be slow to react or prone to false signals during choppy markets, this script utilizes an adaptive logic to smooth out price action while remaining responsive to significant movements.
How the Logic Works
1. Adaptive Smoothing (The AMA Line) The core of this indicator is the Kaufman Adaptive Moving Average (AMA). The primary goal of this logic is to distinguish between "noise" (minor, insignificant price fluctuations) and actual trends.
- Noise Calculation: The script constantly measures the volatility of the market over a specific period. It looks at how much the price is jumping around compared to the total price change.
- Efficiency Ratio: By calculating this ratio, the tool determines how "efficient" the current trend is. If the market is moving sideways with lots of small zig-zags, the script recognizes high noise. If the market is moving decisively in one direction, it recognizes a clear trend.
- Dynamic Adjustment: The indicator automatically adjusts its sensitivity based on this efficiency. In noisy markets, it slows down to prevent "whipsaws" (false signals); in trending markets, it speeds up to follow the price more closely.
2. Trend Visualization The primary visual output is a smooth line that represents the filtered direction of the market. This allows traders to see the underlying "flow" of the asset, making it easier to stay on the right side of the trend without getting distracted by minor price spikes.
3. Signal Identification (Buy & Sell Cues) Beyond just showing a moving average, this script includes an automated signaling system to help identify specific moments of momentum:
- Upward Signals: When the adaptive line moves upward with a force that exceeds a specific pre-defined threshold, the script marks a potential "Buy" or bullish signal.
- Downward Signals: Conversely, when the line drops with sufficient momentum, it marks a potential "Sell" or bearish signal.
- Filtering Mechanism: By using a "Point" threshold (sensitivity), the script ensures that only significant movements trigger these signals, helping traders avoid entering trades based on insignificant price ticks.
Summary for the Trader
This tool acts as a smart filter. It attempts to answer the question: "Is this price move a meaningful trend or just random market noise?" By providing a smoothed trend line combined with specific momentum signals, it helps users visualize the direction of the market while highlighting high-probability movement points.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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