DayImpuls_v1
Download scriptThis tool is designed as a visual market indicator that helps traders identify specific price movements by analyzing historical price trends over a set period. Rather than focusing on standard price levels, it operates by calculating the cumulative momentum of "imbalance"—the difference between opening and closing prices.
How the Logic Works
The indicator functions by scanning through historical data to measure the gap between where a candle opens and where it eventually closes. Here is a breakdown of the process:
1. Data Collection & Time Window The script uses two primary settings to define its scope. It looks back at a specific number of bars (the "Period") and calculates these values across a larger historical window (the "Distance"). This allows the tool to provide context on how price movement behaves over sustained periods rather than just reacting to momentary spikes.
2. Calculating Price Imbalance The core logic focuses on the difference between the Open and Close prices of each candle.
- It sums these differences across a specific window of time.
- By measuring how much "space" was covered between opening and closing, it determines the net direction and strength of the movement.
3. Normalization and Inversion Once the total imbalance is calculated, the script converts that value into a standardized format (points). To ensure the data is represented correctly on the visual display, the script performs an inversion of the result. This step ensures that the visual output aligns with the desired trend direction, making it easier for a trader to see the strength of price momentum at a glance.
4. Visual Representation The final result is plotted as a line in a separate window below the main trading chart. This allows you to observe trends independently of the price action. Instead of looking at the raw price fluctuations, you are viewing a smoothed representation of cumulative price movement, helping to identify significant "impulses" in the market.
Summary for Traders
In short, this script filters out the "noise" of standard price action to show you the underlying momentum. It looks at how much price actually moved relative to where it started over a set period, providing a clearer picture of whether the market is trending with strength or moving without significant conviction.
//+------------------------------------------------------------------+
//| DayImpuls.mq4
//|
//| http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10
//+------------------------------------------------------------------+
#property copyright ""
#property link "http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
//---- input parameters
extern int per=14;
extern int d=100;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int shift,i;
double imp,mBar;
//SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
for( shift=Bars-1; shift>=0; shift--)
//for shift=Bars-1 Downto 0
{
ExtMapBuffer1[shift]=1;
ExtMapBuffer2[shift]=1;
//SetIndexValue(shift,0);
//SetIndexValue2(shift,0);
}
mBar=d*per;
//for shift=mBar downto 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;
ExtMapBuffer1[shift-per]=imp;
}
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments