FX Sniper's MA2

Download script
FX Sniper's MA2

This tool is designed to provide a visual representation of price momentum by analyzing the movement of a Moving Average on your trading chart. Instead of showing a continuous, single line, it works by identifying and highlighting specific shifts in the average's direction.

How the Logic Works

1. Trend Identification The script begins by calculating a standard Moving Average based on parameters you can customize (such as the period length and the type of moving average used). This serves as the foundation for determining the overall "flow" of the market.

2. Comparison Engine The core logic works by constantly comparing the current value of the Moving Average against its previous value. It looks for these two specific scenarios:

  • Upward Movement: If the current average is higher than the previous one, the script recognizes an upward trend.
  • Downward Movement: If the current average is lower than the previous one, the script recognizes a downward trend.

3. Visual Filtering (The "Mapping") Unlike a standard indicator that draws a line across every data point, this script uses a logic of elimination to clarify the direction:

  • When the trend moves up, the script hides the visual data for the upward movement and focuses on marking the progression.
  • When the trend moves down, it performs the opposite action, hiding the downward data to emphasize the drop.

Summary for Traders

Essentially, this script acts as a "direction filter." By suppressing one side of the price movement and highlighting the other, it helps traders visually distinguish between periods of growth and periods of decline more clearly than a standard moving average might allow. It simplifies the chart by focusing your attention on the active direction of the trend.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
FX Sniper's MA2
//+------------------------------------------------------------------+
//|                                                        |
//|                      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 Red      
#property indicator_color2 Lime
#property indicator_width1 1
#property indicator_width2 1


//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];

extern int MAType = 1;
extern int MAPeriod = 50;
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,1);
   SetIndexStyle(1,DRAW_LINE,0,1);


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