FX Sniper's MA[1]

Download script
FX Sniper's MA[1]

This script is designed to provide a visual representation of market momentum by identifying the direction of price movement through a moving average. Instead of simply showing a single continuous line, the tool filters out the data to highlight specific "turns" or shifts in the trend, making it easier for a trader to see where the momentum changes.

How the Logic Works

The script operates using three main logical steps:

1. Trend Calculation First, the tool calculates a moving average based on a set period (the default being 34). This moving average acts as the baseline for determining the overall direction of the market. It smooths out the "noise" of constant price fluctuations to reveal the underlying trend.

2. Comparison Logic The core functionality lies in how the script compares the current moving average value to the previous one. It looks for a change in direction:

  • If the current value is higher than the previous value, it identifies an upward movement.
  • If the current value is lower than the previous value, it identifies a downward movement.

3. Visual Filtering (The "Step" Effect) Rather than drawing a continuous line for both directions simultaneously, the script uses logic to hide segments of the data based on the direction of the move:

  • When the trend is moving up, the script hides the primary upward data points and only highlights specific coordinates to show the progression.
  • When the trend is moving down, it performs the opposite action, hiding the downward data points to clarify the path.

Summary for the User

In practical terms, this script simplifies your chart by acting as a directional filter. Instead of forcing you to interpret a jagged or complex moving average, it visually isolates the "peaks" and "valleys" of the trend. This allows you to see clearly whether the market momentum is currently shifting in one direction or another, helping to identify potential turning points in price action more efficiently.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
FX Sniper's MA[1]
//+------------------------------------------------------------------+
//|                                                        |
//|                      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 Tomato      
#property indicator_color2 LightBlue


//---- 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