Velocity_v1
Download scriptUnderstanding the Velocity Indicator
The Velocity indicator is designed to help traders visualize the speed and momentum of price movements in the financial markets. Rather than simply looking at where the price is currently located, this tool focuses on how quickly the price is changing from one moment to the next. By transforming raw price action into "velocity," it allows you to identify whether a trend is accelerating, decelerating, or losing steam.
How the Logic Works
The indicator functions by breaking down price movement into three distinct layers of calculation:
1. Calculating Raw Velocity At its core, the script looks at the difference between the current closing price and the previous closing price. This tells us the "raw" distance traveled in a single step. If the price moves up significantly, the velocity is high; if it barely moves, the velocity is low.
2. Smoothing the Data (The Fast Component) Raw price changes can be very erratic and "noisy," making them difficult to read clearly on a chart. To solve this, the indicator applies a smoothing technique to the raw velocity. This creates a "Fast" line that follows the overall trend of the momentum while filtering out minor, insignificant market fluctuations.
3. Establishing the Trend (The Slow Component) To provide a broader perspective, the script takes that smoothed fast velocity and processes it a second time using a different timeframe setting. This results in a "Slow" line. This double-layer smoothing helps to filter out even more noise, providing a clearer picture of the long-term momentum of the market.
How to Read the Results
The indicator appears in a separate window below your main price chart and provides two primary lines:
- The Fast Line: Represents the immediate momentum. It reacts quickly to changes in market speed.
- The Slow Line: Represents the broader trend of the velocity. It moves more deliberately and helps confirm if a move is a sustained trend or just a brief spike.
Key Takeaways for Trading:
- Momentum Strength: When both lines are moving upward, it indicates that the price is not only rising but doing so with increasing speed.
- Trend Exhaustion: If the price continues to move in one direction but the Velocity lines begin to flatten or turn downward, it may suggest that the market's "energy" is fading, potentially signaling a coming reversal or consolidation.
- Trend Confirmation: By comparing the Fast line against the Slow line, traders can get a sense of whether the current pace of the market is accelerating relative to its recent history.
//+------------------------------------------------------------------+
//| Velocity_v1.mq4 |
//| Copyright © 2005, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Red
//---- input parameters
extern int VelocityPeriod=8;
extern int Slow=5;
//---- indicator buffers
double FastBuffer[];
double SlowBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(0,FastBuffer);
SetIndexBuffer(1,SlowBuffer);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="Velocity("+VelocityPeriod+","+Slow+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"Fast");
SetIndexLabel(1,"Slow");
//----
SetIndexDrawBegin(0,VelocityPeriod);
SetIndexDrawBegin(1,Slow);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Velocity_v1 |
//+------------------------------------------------------------------+
int start()
{
int shift;
double Vel,Vel1,Vel2,AvgVel,AvgVel1,AvgVel2,AvgVel21;
for(shift=Bars-1-VelocityPeriod;shift>=0;shift--)
{
Vel1=Vel;
AvgVel1=AvgVel;
AvgVel21=AvgVel2;
Vel=(Close[shift]-Close[shift+1])/Point;
AvgVel=AvgVel1+2.0/(1.0+VelocityPeriod)*(Vel-AvgVel1);
AvgVel2=AvgVel21+2.0/(1.0+VelocityPeriod)*(AvgVel-AvgVel21);
FastBuffer[shift]=FastBuffer[shift+1]+2.0/(1.0+VelocityPeriod)*(AvgVel2-FastBuffer[shift+1]);
SlowBuffer[shift]=SlowBuffer[shift+1]+2.0/(Slow+1.0)*(FastBuffer[shift]-SlowBuffer[shift+1]);
}
return(0);
}
Comments