FXSniperMA_SW

Download script
FXSniperMA_SW

The FX Sniper's MA is a specialized technical analysis tool designed for the MetaTrader platform to help traders visualize momentum and trend shifts in real-time. Instead of simply plotting a moving average line on your chart, this script focuses on identifying specific "turning points" where the price momentum changes direction.

How it Works

The core logic of the tool revolves around monitoring the movement of a Moving Average (MA). Depending on your preference, you can choose between several types of averages—such as Simple, Exponential, Smoothed, or Linearly Weighted—which determine how much weight is given to recent price data versus older data.

The script continuously compares the current value of the moving average against its previous value. By analyzing this relationship, it identifies two distinct actions:

  • Upward Momentum: When the moving average rises compared to the previous point, the tool recognizes an upward trend.
  • Downward Momentum: When the moving average falls compared to the previous point, the tool recognizes a downward trend.

Visual Indicators

Rather than cluttering your screen with complex lines, the script uses a signaling system. It places specific visual markers (arrows) on your chart to highlight these shifts:

  1. Directional Signals: The tool creates distinct markers that appear only when the moving average changes direction.
  2. Trend Identification: By observing where these markers appear, traders can quickly see whether the market is currently leaning toward a bullish (upward) or bearish (downward) movement.
  3. Clean Interface: The logic is designed to keep your chart clean by only displaying relevant data points, allowing you to focus on the "snaps" in price action rather than tracking every minor fluctuation.

Key Customizations

The tool is highly adaptable to different trading styles through several adjustable parameters:

  • Average Type: You can switch between different mathematical models (SMA, EMA, SMMA, or LWMA) to suit your specific trading speed.
  • Period: You can define the look-back window (how many candles/bars the tool considers), allowing for both short-term "scalping" signals and longer-term trend analysis.
  • Price Type: The tool can be configured to calculate its data based on various price inputs (such as Close, Open, High, or Low).

In summary, this script acts as a visual filter that translates complex moving average calculations into clear, actionable markers, helping you identify exactly when the market's underlying momentum shifts.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
FXSniperMA_SW
//+------------------------------------------------------------------+
//|                                                   FX Sniper's MA |
//|                                      Copyright © 2006, FX Sniper |
//|FXSniperMA_SW                                                     |
//|Mod. by a1ra                                                      |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2006, FX Sniper "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1 Red    
#property indicator_color2 Lime
#property indicator_width1 1
#property indicator_width2 1
#property indicator_maximum 2
#property indicator_minimum 0
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
string objectma1;

extern double  IndicatorValue = 1;
extern string note1 = "Moving Average Type";
extern string note2 = "0=Simple,1=Exponential";
extern string note3 = "2=Smooth,3=Linear Weighted";
extern int MAType = 3;
extern string note4 = "Moving Average Period";
extern int MAPeriod = 3;
extern int MAShift = 0;
extern int PriceType=0; 


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
   
//---- drawing settings
   SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,167);
   SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,167);
   SetIndexBuffer(2,ma);   
   
   switch(MAType)
     {
      case 1 : short_name="EMA";  break;
      case 2 : short_name="SMMA"; break;
      case 3 : short_name="LWMA"; break;
      default :
         MAType=0;
         short_name="SMA";
     }
   string shortname = "FXSniperMA ("+short_name+","+MAPeriod+","+PriceType+")";
   IndicatorShortName (shortname);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
  ObjectDelete(objectma1);  
  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] = IndicatorValue; 
       ExtMapBuffer2[shift] = IndicatorValue; 
       //Print (ma[shift]);
        if (ma[shift] > ma[shift+1])
        {
        ExtMapBuffer1[shift] = EMPTY_VALUE;
        ExtMapBuffer2[shift+1] =IndicatorValue; 
        
        }
       else if (ma[shift] < ma[shift+1]) 
        {
        ExtMapBuffer2[shift] = EMPTY_VALUE; 
        ExtMapBuffer1[shift+1] =IndicatorValue; 
        }

      }
    
      return(0);
  }
//+------------------------------------------------------------------+



Comments