Speed3
Download scriptThis technical indicator, titled "Speed," is designed to analyze and visualize the velocity of market movements by measuring how price changes relate to trading volume. Unlike standard indicators that might only look at price or only look at volume, this tool attempts to provide a clearer picture of the momentum behind price shifts.
How the Logic Works
Data Collection The script begins by scanning the most recent history of the market. For every point on the chart, it gathers specific data from the current candle and the five preceding candles. This includes the highest and lowest prices reached (High/Low), the opening and closing prices, and the total trading volume for each period.
Establishing Averages To create a stable baseline for its calculations, the script calculates a moving average for three key components over that six-candle window:
- The average Closing Price.
- The average Trading Volume.
- The average price relative to the smallest tradable unit (Pips).
Calculating Momentum Velocity The core logic focuses on identifying "Speed" by comparing the change in volume between consecutive candles against the overall average volume. It specifically looks at the difference between the current candle's volume and the previous one, then normalizes that figure by dividing it by the calculated average volume of the recent period.
This essentially tells the user: "How much faster or slower is the current volume moving compared to the recent norm?"
Cumulative Smoothing The indicator includes a toggleable feature called "Cumulative." When enabled, the script adjusts the final output so that it tracks the running sum of these velocity changes. This transforms the data from a series of isolated "speed bursts" into a continuous trend line, making it easier for traders to see if the market's momentum is building up or slowing down over a longer duration.
Summary of Purpose
In plain terms, this script filters out the "noise" of the market by looking at the relationship between how many people are trading (Volume) and how fast that participation is changing. It provides a visual representation of market intensity, helping to identify whether a price move is being driven by significant momentum or if the market is losing steam.
//+------------------------------------------------------------------+
//| Speed.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
extern bool cumulat=true;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Speed3(V0-V1)/Vm");
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
int i,n,Bars1,counted_bars=IndicatorCounted();
RefreshRates();
//----
//i=0;
//n=Bars-counted_bars-1;
//while(i<=n)
Bars1=Bars/2;
i=Bars1;//Bars-counted_bars-1;
while(i>=0)
{
double high0 =High[i];
double low0 =Low[i];
double open0 =Open[i];
double close0=Close[i];
double pips0=close0/Point;
double vol0=Volume[i];
double high1 =High[i+1];
double low1 =Low[i+1];
double open1 =Open[i+1];
double close1=Close[i+1];
double pips1=close1/Point;
double vol1=Volume[i+1];
double high2 =High[i+2];
double low2 =Low[i+2];
double open2 =Open[i+2];
double close2=Close[i+2];
double pips2=close2/Point;
double vol2=Volume[i+2];
double high3 =High[i+3];
double low3 =Low[i+3];
double open3 =Open[i+3];
double close3=Close[i+3];
double pips3=close0/Point;
double vol3=Volume[i+3];
double high4 =High[i+4];
double low4 =Low[i+4];
double open4 =Open[i+4];
double close4=Close[i+4];
double pips4=close1/Point;
double vol4=Volume[i+4];
double high5 =High[i+5];
double low5 =Low[i+5];
double open5 =Open[i+5];
double close5=Close[i+5];
double pips5=close5/Point;
double vol5=Volume[i+5];
double close_med = (close0+close1+close2+close3+close4+close5)/6;
double vol_med= (vol0+vol1+vol2+vol3+vol4+vol5)/6;
double pips_med= (pips0+pips1+pips2+pips3+pips4+pips5)/6;
double x1=(vol0-vol1);
if(x1==0)x1=1;
double x2=(vol1-vol2);
if(x2==0)x2=1;
double vit1=(close0-close1)/x1;
double vit2=(close1-close2)/x2;
//ExtMapBuffer1[i]=ExtMapBuffer1[i+1]+Volume[i];
ExtMapBuffer1[i]=(vol0-vol1)/vol_med; //(close-low)-(high-close);
/*
if(ExtMapBuffer1[i]!=0)
{
double diff=high-low;
if(0==diff)
ExtMapBuffer1[i]=0;
else
{
ExtMapBuffer1[i]/=diff;
ExtMapBuffer1[i]*=Volume[i];
}
}*/
if((i<Bars1-1) && cumulat)
ExtMapBuffer1[i]-=ExtMapBuffer1[i+1];
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments