DayImpuls_v2
Download scriptThis tool is designed to provide visual feedback on market momentum by analyzing the relationship between opening and closing prices over specific intervals. Instead of looking at individual price movements in isolation, it focuses on the cumulative "imbalance" that occurs within a defined timeframe.
How the Logic Works
The script operates by calculating the difference between the market's opening price and its closing price for a set number of candles (defined by the user as the Period). By adding up these differences across the chosen range, the tool measures the net direction of the price action.
Essentially, it seeks to determine whether the market has consistently closed higher or lower than where it started during that specific window.
Data Processing and Visualization
- Calculation Window: The script looks back at a significant amount of historical data (determined by multiplying two user-defined settings) to ensure it has enough context to generate a stable signal.
- Momentum Extraction: It calculates the total "impulse" by summing the price gaps. If the price consistently closed above the open, it records a positive trend; if it closed below, it records a negative trend.
- Signal Smoothing: The logic converts these raw mathematical differences into a manageable numerical format. It then rounds these values to ensure they are compatible with standard currency digits (such as 4 decimal places).
- Visual Output: The final result is plotted on a separate window below your main price chart. This allows traders to see the "pulse" of the market—where the line moves higher or lower, it indicates the strength and direction of the price momentum relative to the historical period selected.
By isolating this specific behavior, the tool helps users identify periods of sustained movement, making it easier to spot whether the current market trend has sufficient "impetus" to continue.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
/*
* Filename: DayImpulse.mq4
forex-tsd.com
*/
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Magenta
extern int per = 14; // Period for signal
extern int d = 100;
// Buffers for signals
double drawBuffer[];
int init() {
string title = "DayImplus(" + per + ")";
SetIndexStyle(0, DRAW_LINE, 0, 2);
SetIndexBuffer(0, drawBuffer);
// Shift everything forward
//SetIndexShift(0, per);
// Titles for each line
SetIndexLabel(0, "DayImpuls(" + per + ")");
IndicatorShortName(title);
return(0);
}
int start() {
int shift, i, mBar;
double imp;
mBar=d*per;
for(shift = mBar; shift >= per; shift--) {
imp = 0;
for (i=shift; i>=shift-per; i--) {
imp=imp+(Open[i]-Close[i]);
}
imp=MathRound(imp/Point);
if (imp==0) imp=0.0001;
if (imp!=0) {
imp = -imp;
drawBuffer[shift-per] = imp;
}
}
return(0);
}
Comments