VelocityWaves

Author: Copyright c 2010, Vladimir Hlystov
VelocityWaves

This script is a specialized technical analysis tool designed to identify, visualize, and calculate the momentum of market price movements. It operates by breaking down complex price action into distinct "waves" to help traders understand the speed and intensity of the current trend.

Core Logic Overview

The tool functions by identifying significant turning points in the market (highs and lows) and treating the space between these points as individual waves. It then analyzes each wave based on three primary metrics: Height, Time, and Velocity.

1. Structural Identification

The script uses a foundational "Zigzag" logic to filter out minor market noise. By identifying only major structural pivots, it creates a clear history of price swings. It scans back through the recent history to capture a specific number of these trend segments.

2. Wave Analytics

For every identified wave, the script performs three key calculations:

  • Height (Price Change): It measures the raw distance traveled between the start and the end of a wave. This tells you how much the price moved in total.
  • Time Duration: It calculates how long it took for that specific move to occur.
  • Velocity (Speed): By dividing the Price Change by the Time Duration, the script determines the "speed" of the trend. This allows a trader to distinguish between a slow, grinding move and a rapid, explosive price spike.

3. Volume Integration

In addition to price and time, the script incorporates trading volume. It calculates the average volume for each specific wave segment, providing a layer of confirmation regarding how much "effort" or participation was behind a particular price move.

Visual Representation

To make this data accessible at a glance, the script translates these calculations into visual elements on your chart:

  • Trend Blocks: Each wave is represented by a rectangle. The color of these blocks changes based on whether the move was upward (bullish) or downward (bearish).
  • Data Labels: The script places text labels over each wave, providing the specific statistics for that movement, including its height (h), average volume (v), and velocity (s).
  • Real-Time Summary: A live comment is provided on the chart screen, showing the current performance metrics of the most recent active trend.

Practical Application

The primary goal of this logic is to move beyond simply seeing where the price went and instead help you see how it got there. By highlighting the velocity and volume of each trend wave, it enables users to identify whether a current market movement is accelerating, decelerating, or losing momentum.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
VelocityWaves
//+------------------------------------------------------------------+
//|                                                VelocityWaves.mq4 |
//|                               Copyright c 2010, Vladimir Hlystov |
//|                                         http://cmillion.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright c 2010, Vladimir Hlystov"
#property link      "http://cmillion.narod.ru"
//+------------------------------------------------------------------+
 
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
extern bool DrawVisualization = true;
//---- indicator ZIGZAG parameters
extern int Zigzag_Depth    = 12;
extern int Zigzag_Deviation= 5;
extern int Zigzag_Backstep = 3;
//----
extern color WavesColor    = Gray;
extern color TrendUpColor  = Red;
extern color TrendDnColor  = Blue;
extern int   TotalTrend    = 10;
//---- indicator buffers
double HighMapBuffer[];
double LowMapBuffer[];
double Waves[101][2];
//+------------------------------------------------------------------+
int init()
  {
   if (TotalTrend>98) TotalTrend=98;
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,HighMapBuffer);
   SetIndexBuffer(1,LowMapBuffer);
   SetIndexEmptyValue(0,0.0);
   IndicatorShortName("VelocityWaves("+Zigzag_Depth+","+Zigzag_Deviation+","+Zigzag_Backstep+")");
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   double shift_Y = (WindowPriceMax()-WindowPriceMin()) / 45;
   double ZigzagBuffer,H_Wave,S_Wave,V_olum,
          v_tek_trend,s_tek_trend=0,h_tek_trend;
   int n,T_Wave,k,k1,max_bulls_trend,max_bears_trend=1000000,max_bulls,max_bears,
       t_tek_trend;
   string txt,rec;
   int i=0;
   while (true)
   {
      if (n==TotalTrend+2) break;
      ZigzagBuffer=iCustom(NULL, 0, "Zigzag",Zigzag_Depth,Zigzag_Deviation,Zigzag_Backstep,0,i);
      if (ZigzagBuffer!=0) 
      {
         Waves[n][0]=ZigzagBuffer;
         Waves[n][1]=i;
         n++;
      }
      i++;
   }
   for (i=n-2; i>=0; i--)
   {
      T_Wave=(Waves[i+1][1]-Waves[i][1])*Period()/60;
      H_Wave=(Waves[i][0]-Waves[i+1][0])/Point;
      if (T_Wave!=0) S_Wave=H_Wave/T_Wave;
      V_olum=SrVolume(Waves[i+1][1],Waves[i][1]);
      if (max_bulls_trend<H_Wave) {max_bulls_trend=H_Wave;max_bulls=i;}
      if (max_bears_trend>H_Wave) {max_bears_trend=H_Wave;max_bears=i;}
      k=Waves[i][1];k1=Waves[i+1][1];
      if (DrawVisualization)
      {
         txt=StringConcatenate("info  ",i);
         rec=StringConcatenate("trend ",i);
         ObjectDelete(txt);
         ObjectDelete(rec);
         ObjectCreate(rec, OBJ_RECTANGLE, 0, Time[k1],Waves[i+1][0], Time[k],Waves[i][0]);
         if (H_Wave>0) {ObjectSet   (rec, OBJPROP_COLOR, TrendUpColor);}
         else          {ObjectSet   (rec, OBJPROP_COLOR, TrendDnColor);}
         ObjectCreate (txt, OBJ_TEXT,0,Time[k1]+(Time[k]-Time[k1])/2,Waves[i][0],0,0,0,0);
         ObjectSetText(txt, StringConcatenate(" h",H_Wave,
                                              " v",DoubleToStr(V_olum,2),
                                              " s",DoubleToStr(S_Wave,2)
                                              ),8,"Arial");
         ObjectSet   (txt, OBJPROP_COLOR, WavesColor);
         ObjectSet   (rec, OBJPROP_STYLE, STYLE_DOT);
         ObjectSet   (rec, OBJPROP_WIDTH,1);
         ObjectSet   (rec, OBJPROP_BACK, false);
      }
   }
   string name;
   int nullbar=Waves[1][1];
   //t_tek_trend=(TimeCurrent()-Time[nullbar])/60;//*Period();
   t_tek_trend=Waves[1][1]*Period()/60;
   if (Waves[1][0]!=0) h_tek_trend=(Bid-Waves[1][0])/Point; else h_tek_trend=0;
   v_tek_trend=SrVolume(Waves[1][1],0);
   if (t_tek_trend!=0) s_tek_trend=h_tek_trend/(t_tek_trend); else s_tek_trend = 0;
   Comment("h ",DoubleToStr(h_tek_trend,0),
        "   v ",DoubleToStr(v_tek_trend,2),
        "   s ",DoubleToStr(s_tek_trend,2));
return;
}
//+------------------------------------------------------------------+
int deinit()
{
   ObjectsDeleteAll(0,OBJ_TEXT);
   ObjectsDeleteAll(0,OBJ_RECTANGLE);
   return(0);
}
//+------------------------------------------------------------------+
double SrVolume(int start,int end)
{
   double Vol;
   for (int i=start+1; i>=end; i--)
   {
      Vol=Vol+Volume[i];
   }
   if (start!=end) Vol=Vol/(start-end);
   return(Vol);
}
//+------------------------------------------------------------------+

Comments