Overview
The "Speedometer" tool is a visual and alert-based indicator designed to measure the velocity of price movements within a trading platform. Rather than simply showing where the price is, this script calculates how fast the price is moving in a specific direction over a set period of time, providing traders with a clear sense of market momentum.
How the Logic Works
The tool operates by analyzing the relationship between price changes and the passage of time. Here is the step-by-step breakdown of its internal logic:
- Velocity Calculation: The script examines each individual candle on the chart. It takes the difference between the opening price and the closing price and divides it by the time elapsed. By normalizing this data against the minimum price movements (points), it generates a "speed" value.
- Directional Sorting: To make the data easy to read, the script separates these measurements into two distinct categories:
- Upward Speed: Positive velocity values are plotted as one color (representing bullish momentum).
- Downward Speed: Negative velocity values are plotted as a different color (representing bearish momentum).
- Visual Representation: These speeds are displayed in a separate window at the bottom of your chart as a histogram. This allows you to see at a glance whether the market is moving aggressively, sluggishly, or remains stagnant.
Alerts and Customization
The script includes a monitoring system that acts like a "speed limiter" for trading:
- Speed Limit Threshold: You can set a specific numerical limit. The script constantly monitors the current "speed" of the market.
- Automatic Notifications: If the price moves faster than your predefined limit in either an upward or downward direction, the tool will trigger an instant alert on your screen.
- Volume Validation: To ensure the alerts are meaningful and not triggered by insignificant price flickers, the script checks for a minimum amount of trading activity (volume) before notifying you.
Summary for the User
In simple terms, this tool acts as a speedometer for the financial markets. It filters out the noise of standard price action to highlight "fast" moves. By using this, you can identify moments where momentum is peaking or accelerating rapidly, allowing for a more reactive approach to volatile market conditions.
//+------------------------------------------------------------------+
//| Speedometer_v1.mq4 |
//| Copyright © 2006, Forex-TSD.com |
//| Written by IgorAD,igorad2003@yahoo.co.uk |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Tomato
#property indicator_width1 3
#property indicator_width2 3
#property indicator_level1 0
extern int SpeedLimit=0;
double UpSpeed[];
double DnSpeed[];
//double price,prevprice,MaxUpSpeed=-1;
int init()
{
string short_name;
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,UpSpeed);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,DnSpeed);
short_name="Speedometer";
IndicatorShortName(short_name);
SetIndexLabel(0,"Up");
SetIndexLabel(1,"Down");
return(0);
}
int start()
{
int i, counted_bars=IndicatorCounted(),limit;
if ( counted_bars > 0 ) limit=Bars-counted_bars;
if ( counted_bars < 0 ) return(0);
if ( counted_bars ==0 ) limit=Bars-1;
for(i=0;i<limit;i++)
{
double dTime = Period();
if (i==0) dTime = (TimeCurrent()-Time[i])/60.0;
if(dTime > 0)
double Speed = (Close[i]-Open[i])/dTime/Point;
if ( Speed >= 0) {UpSpeed[i]=Speed; DnSpeed[i] = 0;}
else if ( Speed<0) {DnSpeed[i] = Speed; UpSpeed[i] = 0;}
}
//----------
string Message;
if ( SpeedLimit>0 && UpSpeed[0] > SpeedLimit && Volume[0]>1/*&& !UpTrendAlert*/)
{
Message = " "+Symbol()+" M"+Period()+": Exceeding of Speed Limit - BUY";
Alert (Message);
//UpTrendAlert=true; DownTrendAlert=false;
}
if ( SpeedLimit>0 && DnSpeed[0] < -SpeedLimit && Volume[0]>1/*&& !DownTrendAlert*/)
{
Message = " "+Symbol()+" M"+Period()+": Exceeding of Speed Limit - SELL";
Alert (Message);
//DownTrendAlert=true; UpTrendAlert=false;
}
//----
return(0);
}
Comments