AMA_&_AMA_sig
Download scriptThis tool is designed to provide traders with a visual representation of market trends and specific entry points by analyzing price movement. It works by calculating a specialized moving average that adapts to the market's current "volatility" or noise level, rather than just relying on a simple historical average.
How the Logic Works
1. Trend Identification (The Moving Average) The core of the script is a dynamic line that tracks the price. Unlike standard averages that can be slow to react or too sensitive to "fake-out" movements, this logic calculates an Efficiency Ratio. It compares the net change in price over a specific period against the total "noise" (the sum of all small fluctuations) during that same timeframe. This allows the line to remain smooth during choppy markets but react quickly when a clear trend emerges.
2. Signal Detection (Up and Down Arrows) The script goes beyond just drawing a line; it actively monitors the direction and strength of the price movement relative to that moving average. It looks for specific "breaks" in momentum:
- Buy Signals: When the calculated average moves upward by a certain significant amount (exceeding a user-defined threshold), the script identifies a bullish momentum shift and places a marker on the chart.
- Sell Signals: Conversely, when the average moves downward by a significant amount, it identifies a bearish momentum shift and marks the opposite direction.
3. User Customization The logic includes several adjustable parameters that allow you to fine-tune the sensitivity of the tool:
- Period Settings: You can define how many candles the script looks back at to determine the trend.
- Fast/Slow Scales: These help balance how quickly the indicator reacts to new price information versus how much it ignores minor fluctuations.
- Sensitivity Thresholds (G and dK): These act as "filters." They ensure that the script only gives you a signal when the move is strong enough to be meaningful, helping to filter out insignificant market "hiccups."
Summary for the Trader
Essentially, this tool acts as a smart filter. It cleans out the visual noise of the market to show you the primary trend. When the price moves with enough consistency and strength in one direction, the script validates that move by displaying specific visual signals, helping you identify potential entry points based on confirmed momentum.
//+------------------------------------------------------------------+
//| AMA&AMAsig.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by GOODMAN & Mstera è AF "
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Brown
//---- 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, 1);
SetIndexStyle(1, DRAW_ARROW, 0, 2);
SetIndexArrow(1, 159);
SetIndexStyle(2, DRAW_ARROW, 0, 2);
SetIndexArrow(2, 159);
SetIndexBuffer(0, kAMAbuffer);
SetIndexBuffer(1, kAMAupsig);
SetIndexBuffer(2, kAMAdownsig);
//----
IndicatorDigits(4);
//----
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);
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