MomentumVT
Download scriptThis script is designed to help traders visualize the "velocity" of price movements by calculating a specific type of momentum. Rather than just looking at where the price is currently sitting, this tool measures the distance and direction the price has traveled over a specific period of time.
How the Logic Works
1. The Time Horizon (Period) The script starts with a user-defined setting called the "Momentum Period." This represents the window of time the indicator looks back at. For example, if you set this to 10, the tool focuses on the relationship between the current price and the price from 10 bars ago.
2. The Calculation The core logic is straightforward: it identifies the closing price of the most recent bar and subtracts the closing price from the bar that occurred exactly "X" periods ago (based on your chosen setting).
- Positive Momentum: If the current price is higher than the price from the start of the period, the indicator shows a positive value. This suggests an upward trend or increasing buying pressure.
- Negative Momentum: If the current price is lower than the price from the start of the period, the indicator shows a negative value. This suggests a downward trend or increasing selling pressure.
- Neutrality: If the prices are identical, the indicator sits at zero, representing no net movement over that timeframe.
3. Visual Representation The results are plotted on a separate window below your main price chart as a continuous line. By watching the height and direction of this line, you can quickly see if the market's strength is accelerating, slowing down, or reversing.
Summary for Traders
Essentially, this script acts as a "speedometer" for the market. It strips away the noise of minor fluctuations and highlights the net movement over a specific timeframe, helping you identify whether the prevailing trend has enough strength to sustain itself or if it is losing steam.
//+--------------------------------------------------------------------+
//| 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
//---- input parameters
extern int MomPeriod=10;
//---- buffers
double MomBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MomBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="Mom("+MomPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,MomPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=MomPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(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--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments