Speed5
Download scriptThis script functions as a custom technical indicator designed to provide visual data on a separate window within your trading platform. Rather than showing traditional price action, it focuses on identifying patterns through a mathematical calculation based on historical bar data and volume.
How the Logic Works
1. Data Collection The script systematically scans through historical price bars, specifically looking at the last half of the available chart history. For every bar it examines, it captures five key pieces of information: the High, Low, Open, Close, and Volume. It compares each current bar against the two preceding bars to establish a chronological sequence.
2. Movement and Volatility Analysis The logic calculates the change in volume and price movement between these consecutive bars. By measuring the difference in volume and dividing the price changes by those volume differences, the script attempts to determine the "velocity" or rate of change within the market. It specifically looks at:
- The difference between closing prices.
- The total range (the distance between the high and low) of each bar relative to the trading volume.
3. The Core Calculation The indicator utilizes a trigonometric approach (specifically a Cosine function) to generate its primary data point. It incorporates the position of the bar on the chart (the index) to create a repeating wave pattern. This ensures that the visual output is structured and consistent over time.
4. Smoothing and Progression To create a fluid line rather than jagged, disconnected points, the script applies a subtraction logic. It takes the current calculated value and subtracts the value of the previous bar. This process helps smooth out the data, allowing for a continuous visual representation that highlights shifts in momentum or trend cycles.
Visual Representation
The result is displayed as two distinct lines on a separate indicator window:
- LightSeaGreen Line: Represents the primary calculated movement.
- Red Line: Provides a secondary comparative data point.
By observing these lines, traders can look for shifts in the "speed" or rhythm of the market, using the visual waves to help identify potential momentum changes or areas of exhaustion in price action.
//+------------------------------------------------------------------+
//| 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 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("");
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
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 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;
double vit3=(high0-low0)/x1;
double vit4=(high1-low1)/x2;
//ExtMapBuffer1[i]=ExtMapBuffer1[i+1]+Volume[i];
ExtMapBuffer1[i]=MathCos(2*3.1415*i/Point);//(close0-close1);//iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)-iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1);//buy //-vit4; //(close-low)-(high-close);
//ExtMapBuffer2[i]=-i;//vit3*20;//-(iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)-iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1));//sell
/*
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)
{
ExtMapBuffer1[i]-=ExtMapBuffer1[i+1];
//ExtMapBuffer2[i]-=ExtMapBuffer2[i+1];
}
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments