Velocity_v2_v1

Download script
Author: Copyright � 2006, TrendLaboratory
Velocity_v2_v1

The Velocity v2 indicator is designed to analyze the momentum and speed of price movements within a trading chart. Rather than simply looking at where the price is currently located, this tool focuses on how fast the price is moving in a specific direction, helping traders identify the strength behind a trend.

How the Logic Works

The script operates by performing a multi-layered calculation that "smooths out" raw market data to reveal underlying trends. It follows a logical progression through five distinct stages:

  1. Price Velocity Tracking: First, the tool calculates the immediate change in price from one candle to the next. This represents the raw "speed" of the market at any given moment.
  2. Initial Smoothing: Because raw price movements can be erratic and "noisy," the script takes that initial velocity and calculates a moving average. This helps stabilize the data, making it easier to see the general direction of the speed.
  3. Double Smoothing: The tool then applies a second layer of averaging to the previous result. By doing this twice, the script filters out significant market "jitter" while preserving the core direction of the price momentum.
  4. Fast Trend Identification: A third smoothing pass is applied to create a "Fast" indicator line. This represents the primary trend of the market's velocity over a set period.
  5. Slow Trend Confirmation: Finally, the script calculates a "Slow" indicator line based on the Fast line.

Visual Interpretation

The final output displays two main components on your chart:

  • Fast Component: This reacts more quickly to changes in market speed.
  • Slow Component: This acts as a long-term baseline, providing a broader perspective on the trend.

By comparing these two values, traders can visually identify when the market is accelerating, decelerating, or potentially reversing. When the "Fast" and "Slow" components move in harmony, it suggests a strong, established trend; when they begin to diverge or cross, it may indicate that the momentum of the current price movement is losing steam.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Velocity_v2_v1
//+------------------------------------------------------------------+
//|                                                  Velocity_v2.mq4 |
//|                                Copyright © 2006, TrendLaboratory |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory"
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"
//----
#property indicator_separate_window
#property indicator_buffers 2
//----
#property indicator_color1 LightBlue
#property indicator_color2 Tomato
#property indicator_width1 2
#property indicator_width2 1
#property indicator_style2 2
//---- input parameters
extern int VelocityPeriod  =8;
extern int Slow            =5;
extern int MA_Mode         =1;
//---- indicator buffers
double FastBuffer[];
double SlowBuffer[];
double Vel[];
double AvgVel[];
double DbAvgVel[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,FastBuffer);
   SetIndexBuffer(1,SlowBuffer);
   SetIndexBuffer(2,Vel);
   SetIndexBuffer(3,AvgVel);
   SetIndexBuffer(4,DbAvgVel);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="Velocity("+VelocityPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Fast");
   SetIndexLabel(1,"Slow");
//----
   SetIndexDrawBegin(0,3*VelocityPeriod+Slow);
   SetIndexDrawBegin(1,3*VelocityPeriod+Slow);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Velocity_v2                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int    shift, limit, counted_bars=IndicatorCounted();
   if(counted_bars < 0)return(-1);
   if(counted_bars ==0)limit=Bars-3*VelocityPeriod-Slow-1;
   if(counted_bars < 1)
      for(int i=1;i<3*VelocityPeriod+Slow;i++)
        {
         Vel[Bars-i]=0;
         AvgVel[Bars-i]=0;
         DbAvgVel[Bars-i]=0;
         FastBuffer[Bars-i]=0;
         SlowBuffer[Bars-i]=0;
        }
   if(counted_bars>0) limit=Bars-counted_bars;
   limit--;
//----
   for(shift=limit;shift>=0;shift--)
      Vel[shift]=(Close[shift]-Close[shift+1])/Point;
   for(shift=limit;shift>=0;shift--)
      AvgVel[shift]=iMAOnArray(Vel,0,VelocityPeriod,0,MA_Mode,shift);
   for(shift=limit;shift>=0;shift--)
      DbAvgVel[shift]=iMAOnArray(AvgVel,0,VelocityPeriod,0,MA_Mode,shift);
   for(shift=limit;shift>=0;shift--)
      FastBuffer[shift]=iMAOnArray(DbAvgVel,0,VelocityPeriod,0,MA_Mode,shift);
   for(shift=limit;shift>=0;shift--)
      SlowBuffer[shift]=iMAOnArray(FastBuffer,0,Slow,0,MA_Mode,shift);
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments