FX Sniper's MACD Lines

Download script
FX Sniper's MACD Lines

This custom trading indicator is designed to provide traders with a visual representation of market momentum and trend strength by utilizing the Moving Average Convergence Divergence (MACD) methodology. It operates in a separate window from the main price chart, allowing users to monitor independent technical data without cluttering the primary price action.

Core Functionality

The tool processes historical price data to identify trends through three distinct visual components:

  • Primary Trend Line (Blue): This represents the "Main" line of the MACD. It tracks the relationship between two different moving averages—one faster and one slower. By comparing these two, it helps smooth out market "noise" to reveal the underlying direction of the price movement.
  • Signal Line (Red): This is a secondary smoothed average of the main trend line. It acts as a trigger; when the primary line crosses this signal line, it often suggests a potential shift in momentum or a new entry point for a trade.
  • Momentum Histogram (Dark Gray): This visual element calculates the mathematical distance between the Main line and the Signal line. By displaying this as a histogram, it provides an immediate visual cue of how strong the current trend is. When the bars are tall, momentum is high; when they shrink, the trend may be losing steam.

User Customization

The logic includes three adjustable parameters that allow you to tailor the sensitivity of the indicator to different timeframes or asset classes:

  1. Fast Period: Determines how quickly the indicator reacts to recent price changes.
  2. Slow Period: Defines the longer-term trend basis.
  3. Signal Period: Controls the smoothing of the signal line to reduce false alerts.

Practical Application

By observing these three elements together, a trader can distinguish between a strong, sustained move and a weak, fluctuating price action. The interaction between the blue and red lines provides the "direction," while the gray histogram provides the "velocity" of the market's current movement.

Indicators Used
MACD Histogram
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
FX Sniper's MACD Lines
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/



#property link      ""
#property  indicator_buffers 3
#property indicator_separate_window
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 DarkGray


//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
extern int Fast = 12;
extern int Slow = 26;
extern int Signal = 9;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   //IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(0,Buffer1);
   SetIndexBuffer(1,Buffer2);
   SetIndexBuffer(2,Buffer3);   
    

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here
  
   for(int i=Bars;i>=0;i--){
      Buffer1[i]=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,i); 
      Buffer2[i]=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_SIGNAL,i);     
      Buffer3[i]=Buffer1[i] - Buffer2[i];
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments