i-HighLow
Download scriptThis tool is designed to provide a visual representation of price extremes on your trading chart by identifying specific high and low points within a rolling window of time. It helps traders identify the "boundaries" of recent market movement, making it easier to see where the price has peaked or bottomed out over a set period.
How the Logic Works
The script functions by constantly scanning the history of the currency pair or asset you are viewing. Here is the step-by-step breakdown of its logic:
- Dynamic Window Scanning: The tool looks back at a specific number of previous price bars (defined by the user). Instead of looking at the entire chart history at once, it focuses on a "moving window." This means that as new candles form, the indicator constantly updates its calculation to reflect only the most recent data.
- Identifying Extremes: Within that moving window, the script performs two primary searches:
- It identifies the highest price reached during that period.
- It identifies the lowest price reached during that period.
- Adding a Buffer Zone: To ensure the lines aren't sitting exactly on the "tip" of the candle (which can sometimes make them hard to see or lead to false signals), the script adds and subtracts a small, customizable margin (an offset).
- The Upper Line is placed slightly above the highest point found.
- The Lower Line is placed slightly below the lowest point found.
- Visual Output: The result is two distinct lines on your chart: a Gold line representing the recent ceiling and a DodgerBlue line representing the recent floor.
Practical Application
By displaying these boundaries, the logic allows you to see the "range" of the market at a glance. It helps in identifying areas where the price might face resistance (the upper boundary) or support (the lower boundary), providing a clearer picture of the current market structure without the clutter of complex mathematical formulas.
//+------------------------------------------------------------------+
//| i-HighLow.mq4 |
//| Copyright © 2007, RickD |
//| Àëåêñàíäúð Ïëàìåíîâ Ðÿäêîâ |
//| http://www.e2e-fx.net |
//+------------------------------------------------------------------+
#property copyright "© 2007 RickD"
#property link "www.e2e-fx.net"
//----
#define major 1
#define minor 0
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 DodgerBlue
//----
extern int N = 20;
extern int N2 = 5;
//----
double UpperBuf[];
double LowerBuf[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
//----
SetIndexDrawBegin(0, N);
SetIndexDrawBegin(1, N);
//----
SetIndexBuffer(0, UpperBuf);
SetIndexBuffer(1, LowerBuf);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void deinit()
{
//----
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void start()
{
int counted = IndicatorCounted();
//----
if(counted < 0)
return (-1);
//----
if(counted > 0)
counted--;
int limit = Bars - counted;
//----
for(int i = 0; i < limit; i++)
{
UpperBuf[i] = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N,
i)) + N2*Point;
LowerBuf[i] = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i)) -
N2*Point;
}
}
//+------------------------------------------------------------------+
Comments