_Drive
Download scriptOverview of the "Drive" Indicator
The "Drive" script is a technical analysis tool designed to measure and visualize market momentum by calculating the relative strength of price movement. Instead of simply looking at whether a price went up or down, this indicator focuses on the "intensity" or "drive" behind those movements over a specific period.
How the Logic Works
The core functionality of this script relies on three main components:
1. The Depth Parameter The indicator uses a user-defined setting called "Depth." This determines the look-back window—essentially how many past candles the script evaluates at any given moment to calculate current market energy. A higher depth means the indicator considers a longer period of history, while a lower depth makes it more sensitive to immediate, recent changes.
2. Measuring Upward and Downward Intensity For every candle within that "Depth" window, the script performs two distinct calculations:
- Upward Drive: It looks at the distance between the Highs and the Opens, as well as the Closes and the Lows. By totaling these values, it captures how much of the price action was pushed toward the top of the candle's range.
- Downward Drive: Similarly, it calculates the distance between the Opens and the Lows, and the Highs and the Closes. This captures the force behind movements pushing toward the bottom of the range.
3. Data Normalization Once the script totals these values for the entire period, it averages them out to ensure the data is consistent and readable. It then converts these raw figures into a numerical format that can be plotted on your chart as two separate lines:
- Green Line (DriveUp): Represents the cumulative strength of the bullish (upward) momentum.
- Red Line (DriveDn): Represents the cumulative strength of the bearish (downward) momentum.
Visual Interpretation
By observing these two lines, a trader can see which side has the "drive." When the green line is higher or trending upward significantly, it indicates that the market is experiencing stronger bullish pressure. Conversely, a rising red line suggests that売り (selling) pressure is dominating the current price action. The gap between these two lines provides a visual representation of the imbalance between buying and selling forces in the market.
//+------------------------------------------------------------------+
//| Drive.mq4 |
//| Copyright © 2005, systrad5 |
//| 25/07/05 |
//| Feedback or comments welcome at systrad5@yahoo.com |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- input parameters
extern int Depth = 16;
//---- buffers
double UpBuffer[];
double DownBuffer[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//---- additional buffers
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, UpBuffer);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, DownBuffer);
//---- name for DataWindow and indicator subwindow label
string short_name = "Drive(" + Depth + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, "DriveUp");
SetIndexLabel(1, "DriveDn");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i, j;
double UpCnt, DnCnt;
if(Bars <= Depth + 10)
return(0);
//---- last counted bar will be recounted
int counted_bars = IndicatorCounted();
int limit = Bars - counted_bars;
if(counted_bars > 0)
limit++;
//---- Load prices into CBuffer[0]
for(i = 0; i < limit; i++)
{
UpCnt = 0;
DnCnt = 0;
for(j = 0; j < Depth; j++)
{
UpCnt = UpCnt + (High[i+j] - Open[i+j]) + (Close[i+j] - Low[i+j]);
DnCnt = DnCnt + (Open[i+j] - Low[i+j]) + (High[i+j] - Close[i+j]);
}
UpBuffer[i] = (UpCnt / (2 * Depth)) / Point;
DownBuffer[i] = (DnCnt / (2 * Depth)) / Point;
}
return(0);
}
//+------------------------------------------------------------------+
Comments