MOM-TC_v2m_001

Download script
MOM-TC_v2m_001

This technical tool is designed to help traders visualize market momentum and identify specific price movements by analyzing the speed and strength of price changes. Instead of just showing where the price is, it focuses on the "force" behind the movement, helping users distinguish between active trends and stagnant periods.

Core Functionality

The script calculates a Momentum indicator based on a user-defined period (defaulting to 14). It transforms this data into a visual format in a separate window below the main chart, allowing traders to see whether the market is accelerating in a positive or negative direction.

Visual Components and Logic

The tool uses several layers of visual information to guide the trader:

  • Trend Identification (Histograms): The script automatically categorizes momentum into "Up" or "Down" trends based on whether the value is above or below a neutral baseline. It renders these as colored histograms, providing an immediate sense of the current market bias.
  • Directional Signals (Arrows): The indicator places specific visual markers (arrows) to highlight when the trend shifts. This serves as a quick reference point for when the momentum has officially flipped from bullish to bearish or vice versa.
  • Dynamic Tracking: It includes a tracking mechanism that follows the momentum movement, highlighting specific "Down" movements visually to help identify sustained periods of selling pressure.

Level Alerts and Crossing Logic

One of the primary features of this script is its multi-level alert system. Rather than just watching the general trend, the tool monitors five specific price thresholds:

  1. Overbought Levels: High positive momentum zones.
  2. Oversold Levels: High negative momentum zones.
  3. Neutral/Zero Level: The baseline for identifying the primary trend direction.

The logic is designed to trigger a notification whenever the momentum "crosses" any of these pre-defined levels. For example, if the momentum moves from an oversold state back toward a neutral state, or pushes into an overbought zone, the script identifies this transition as a significant event.

User Experience

The tool is built for proactive trading. By combining visual histograms, trend arrows, and real-time alerts, it provides a comprehensive view of market "heat." Traders can see at a glance whether a move is gaining strength or losing steam, while the alert system ensures they are notified immediately when price momentum breaches critical levels, potentially signaling a reversal or an exhaustion point in the market.

Indicators Used
Momentum indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
10 Views
0 Downloads
0 Favorites
MOM-TC_v2m_001
/*

//+------------------------------------------------------------------+
//|                         Momentum with Alert Cross and signal.mq4 |
//|                                                                  |
//|   Original: RSI with Trend Catcher signal by Matsu               |  
//|   Modified: Momentum with cross signal by Linuxser for Forex-TSD |
//| Modified by kalenzo, bartlomiej.gorski@gmail.com
//+------------------------------------------------------------------+

*/
//mod

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 LimeGreen
#property indicator_color2 LimeGreen
#property indicator_color3 Orange
#property indicator_color4 Orange
#property indicator_color5 LimeGreen
#property indicator_color6 Orange


#property indicator_levelcolor Brown
#property indicator_levelstyle STYLE_DOT


extern int       MOMPeriod=14;
extern int       MOMPrice=0;


extern double       obLevel2= 0.8;
extern double       obLevel1= 0.5;
extern double       Level0  = 0;
extern double       osLevel1=-0.5;
extern double       osLevel2=-0.8;





extern bool      Alerts = true;

extern bool       alertLevels2 =1;
extern bool       alertLevels1 =1;
extern bool       alertLevel0  =1;

extern bool       alertOBCrossUp=1;
extern bool       alertOBCrossDn=1;
extern bool       alertOSCrossUp=1;
extern bool       alertOSCrossDn=1;

double MOM[];
double Buy[];
double Sell[];
double DnMOM[];
double Levela[];
double hUP[],hDN[];
int Level= 0;



int init() 
{

   IndicatorBuffers(6);
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MOM);
   
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(1,159);
   SetIndexBuffer(1,Buy);
   
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(2,159);
   SetIndexBuffer(2,Sell);
   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,DnMOM);
   
   SetIndexBuffer(4,hUP);
   SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
   
   SetIndexBuffer(5,hDN);
   SetIndexStyle(5,DRAW_HISTOGRAM,STYLE_SOLID,1);
   
   
   SetLevelValue(0,obLevel2);
   SetLevelValue(1,obLevel1);
   SetLevelValue(2,osLevel1);
   SetLevelValue(3,osLevel2);
   
   
   
   
   IndicatorShortName("Momentum ("+MOMPeriod+")");
   IndicatorDigits(2);
   
   return(0);
   
}



int start() 
{

   int counted_bars=IndicatorCounted();
   int shift,limit,ob,os;   
   bool TrendUp, TrendDn;
   bool dn = false;
   double BuyNow, BuyPrevious, SellNow, SellPrevious;
   static datetime prevtime = 0;
         
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-31;
   if(counted_bars>=31) limit=Bars-counted_bars-1;

   for (shift=limit;shift>=0;shift--)   
   {
            

      MOM[shift]=iMomentum(NULL,0,MOMPeriod,MOMPrice,shift)-100;

      ob = Level;
      os = Level;
      
      
      TrendUp=false;
      TrendDn=false;
      

      if(MOM[shift]>Level0) 
	  {
		TrendUp=true;
		hUP[shift] = MOM[shift];
		hDN[shift] = 0;
	  }	
      else if(MOM[shift]<=Level) 
	  {
		TrendDn=true;
		hDN[shift] = MOM[shift];
		hUP[shift] = 0;
	  }	 
      
      if (dn==true)
      {
         if (MOM[shift]>Level) 
         {
            dn=false;
            DnMOM[shift]=EMPTY_VALUE;
         }
         else
         {
            dn=true;
            DnMOM[shift]=MOM[shift];
			
         }

      }
      else
      {
         if (MOM[shift]<Level) 
         {
            dn=true;
            DnMOM[shift]=MOM[shift];
		 }
         else
         {
            dn=false;
            DnMOM[shift]=EMPTY_VALUE;
			
         }
           
      }
      
      


      if(TrendUp==true) 
      {
         Buy[shift]=ob;
         Sell[shift]=EMPTY_VALUE;
      } 
      else 
      if(TrendDn==true) 
      {
         Buy[shift]=EMPTY_VALUE;
         Sell[shift]=os;
      } 
      else
      {
         Buy[shift]=EMPTY_VALUE;
         Sell[shift]=EMPTY_VALUE;
      }
      
    }      
         

//       ======= Alert =========

   if(Alerts)
   {
      // if(prevtime == Time[0]) return(0);
      
         
     
   
     double  MOMNow = MOM[0];
     double  MOMPrev = MOM[1];
      


  bool cross=0, lv0cross=0, lv1cross=0, lv2cross=0;
  string  mess;
  
     
  
      if    (MOMNow >Level0   && MOMPrev<=Level0     && alertLevel0) 
                                          {cross=1; mess =   "0 UP";}

      if    (MOMNow <Level0   && MOMPrev>=Level0     && alertLevel0) 
                                          {cross=1; mess =   "0 DN";}
 
     
     
      if    (MOMNow >obLevel1 && MOMPrev<=obLevel1  && alertLevels1 && alertOBCrossUp)
                                          {cross =1; mess =  DoubleToStr(obLevel1,2)+"  UP";}

      if    (MOMNow <obLevel1 && MOMPrev>=obLevel1  && alertLevels1 && alertOBCrossDn)
                                          {cross =1; mess =  DoubleToStr(obLevel1,2)+"  DN";}


      if    (MOMNow >obLevel2 && MOMPrev<=obLevel2  && alertLevels2 && alertOBCrossUp) 
                                          {cross =1; mess =  DoubleToStr(obLevel2,2)+"  UP";}

      if    (MOMNow <obLevel2 && MOMPrev>=obLevel2  && alertLevels2&& alertOBCrossDn)
                                          {cross =1; mess =  DoubleToStr(obLevel1,2)+"  DN";}





      if    (MOMNow >osLevel1 && MOMPrev<=osLevel1  && alertLevels1 && alertOSCrossUp) 
                                          {cross =1; mess =  DoubleToStr(osLevel1,2)+"  UP";}

      if    (MOMNow <osLevel1 && MOMPrev>=osLevel1  && alertLevels1 && alertOSCrossDn)
                                          {cross =1; mess =  DoubleToStr(osLevel1,2)+"  DN";}



      if    (MOMNow >osLevel2 && MOMPrev<=osLevel2  && alertLevels2 && alertOSCrossUp) 
                                          {cross =1; mess =  DoubleToStr(osLevel2,2)+"  UP";}

      if    (MOMNow <osLevel2 && MOMPrev>=osLevel2  && alertLevels2 && alertOSCrossDn)
                                          {cross =1; mess =  DoubleToStr(osLevel2,2)+"  DN";}


     if (cross && prevtime != Time[0]) {
      
         Alert(Symbol(), " M", Period(), " Momentum Cross level " +mess );
   
         
         IndicatorShortName("Momentum ("+MOMPeriod+") (alerts on)");
         prevtime = Time[0];            }

   }

//       ======= Alert End =========


   
   return(0);
   
}



Comments