FX Sniper's MA
Download scriptThis tool is designed to provide traders with a clear visual representation of market momentum by analyzing the movement of price averages. Instead of just showing a single, continuous line, this script identifies specific shifts in direction to help distinguish between upward and downward trends more effectively.
Core Logic Overview
The script operates by calculating a Moving Average—a mathematical tool that smooths out daily price fluctuations to reveal the underlying trend. It then evaluates the relationship between the current value of this average and its previous value to determine the "flow" of the market.
How it Works
- Trend Identification: The tool looks at whether the moving average is currently rising or falling.
- When the average moves upward, the script recognizes an appreciative trend.
- When the average moves downward, it recognizes a depreciative trend.
- Visual Distinction: Rather than drawing one unbroken line, the logic separates these movements into two distinct visual categories. It assigns different behaviors to the data based on direction:
- Upward Movement: When the price momentum is positive, the script highlights the progression of the rise.
- Downward Movement: When the price momentum turns negative, the script captures the descent.
- Dynamic Filtering: By evaluating the change from one point to the next (comparing a current point to the one immediately preceding it), the tool effectively "filters" the data. It only displays specific segments of the moving average that align with the current direction, helping to strip away visual clutter and highlight the most relevant trend information.
Summary for the Trader
Essentially, this script acts as a directional filter. It takes a standard moving average and breaks it down so that you can see exactly where the momentum is shifting. By visually isolating the "up" movements from the "down" movements, it allows you to identify trend changes more intuitively on your chart.
//+------------------------------------------------------------------+
//| |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, FX Sniper "
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
extern int MAType = 1;
extern int MAPeriod = 34;
extern int MAShift = 0;
extern int PriceType=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ma);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexStyle(1,DRAW_LINE,0,2);
//---- initialization done
return(0);
}
int start()
{
for(int i = Bars-10; i >= 0; i--)
{
ma[i]=iMA(NULL,0,MAPeriod,MAShift,MAType,PriceType,i);
}
for(int shift = Bars-10; shift >= 0; shift--)
{
ExtMapBuffer1[shift] = ma[shift];
ExtMapBuffer2[shift] = ma[shift];
//Print (ma[shift]);
if (ma[shift] > ma[shift+1])
{
ExtMapBuffer1[shift] = EMPTY_VALUE;
ExtMapBuffer2[shift+1] = ma[shift+1];
}
else if (ma[shift] < ma[shift+1])
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
ExtMapBuffer1[shift+1] = ma[shift+1];
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments