MomentumVT_alertOC

Author: Copyright � 2004, MetaQuotes Software Corp.
MomentumVT_alertOC

This script is designed as a specialized technical analysis tool for the MetaTrader platform. Its primary purpose is to measure and visualize "Momentum"—the speed and strength of price movement—over a specific timeframe.

Core Functionality

The tool calculates the difference between the current market price and the price from a set number of bars ago (determined by the user). By subtracting these two values, the script identifies whether the price is trending upward or downward relative to its past position.

  • Positive Values: Indicate that the current price is higher than it was in the previous period, suggesting bullish momentum.
  • Negative Values: Indicate that the current price is lower than it was in the previous period, suggesting bearish momentum.

Visual Representation

The script displays this information as a continuous line in a separate window below your main trading chart. This allows you to see at a glance whether the market's strength is accelerating, decelerating, or shifting direction.

Smart Alert System

Beyond just providing a visual line, the script includes an automated notification system to help traders identify critical turning points. It monitors the momentum line for "Zero Crosses"—the specific moments when momentum shifts from positive to negative (or vice versa).

The alerts are highly customizable:

  • Immediate Alerts: The system can notify you the very instant the momentum crosses the zero line during a live bar.
  • Confirmed Alerts: Alternatively, you can configure it to wait until a candle officially closes before sending a notification, which helps filter out "noise" and prevents false signals from mid-bar fluctuations.

User Experience Features

  • Audio Feedback: If configured, the script will play a specific sound file when a momentum shift occurs, ensuring you don't miss a trend change while away from your screen.
  • Customizable Timeframes: You can easily adjust the "Momentum Period" to make the tool more sensitive (looking at shorter timeframes) or smoother (looking at longer periods), depending on your specific trading style.
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt plays sound alerts
11 Views
0 Downloads
0 Favorites
MomentumVT_alertOC
//+--------------------------------------------------------------------+
//|                                                     MomentumVT.mq4 |
//|                        Copyright © 2004, MetaQuotes Software Corp. |
//|                                         http://www.metaquotes.net/ |
//|             Conversion from VT to MT4 by Skyline (glicci@yahoo.it) |
//+--------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//#property indicator_level1 0
#property indicator_levelcolor SlateGray

//---- input parameters
extern bool AlertsEnabled  = true;
extern bool AlertAfterBarClose = false;

extern string AlertsSound = "alert.wav";

extern int MomPeriod = 10;

//---- buffers
double MomBuffer[];
datetime AlertTime;


void init()
{
	//---- indicator line
	SetIndexStyle(0, DRAW_LINE);
	SetIndexBuffer(0, MomBuffer);
	
	//---- name for DataWindow and indicator subwindow label
	string short_name="MomentumVT alert(" + MomPeriod + ")";
	IndicatorShortName(short_name);
	SetIndexLabel(0, short_name);
	
	//----
	SetIndexDrawBegin(0, MomPeriod);
}

//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
void start()
{
	
	int counted_bars = IndicatorCounted();
	if (Bars <= MomPeriod)
		return;
	
	//---- initial zero
	if (counted_bars < 1)
		for (int i = 1; i <= MomPeriod; i++)
			MomBuffer[Bars - i] = 0.0;
	
	//----
	i = Bars - MomPeriod - 1;
	if (counted_bars >= MomPeriod)
		i = Bars - counted_bars - 1;
	while (i >= 0) {
		MomBuffer[i] = Close[i] - Close[i + MomPeriod];
		i--;
		
		if (AlertsEnabled  && AlertTime != Time[0]&& Volume[0]>1) 
		{
	
			if ((AlertAfterBarClose  && (MomBuffer[1] > 0 && MomBuffer[2] <= 0) || (MomBuffer[1] < 0 && MomBuffer[2] >= 0)) ||
		      (!AlertAfterBarClose  && (MomBuffer[0] > 0 && MomBuffer[1] <= 0) || (MomBuffer[0] < 0 && MomBuffer[1] >= 0))  )
			{

				AlertTime = Time[0];
				Alert("MomentumVT Cross 0 ", Symbol(), " M", Period());

		    if (StringLen(AlertsSound) > 0)
					PlaySound(AlertsSound);
			}
		}
	}
}

Comments