Overview
The Range_v2 tool is a specialized market analysis indicator designed to help traders identify broader market trends by visualizing and consolidating high-level price action. Instead of reacting to the "noise" of small, rapid price fluctuations, this script filters the data to provide a smoother, more coherent picture of where the market is heading over a specific period.
Core Logic and Functionality
The primary objective of this script is Multi-Timeframe Analysis. It works by pulling data from a higher time interval (such as Daily or Weekly charts) and projecting that information onto your current viewing window. This allows you to see the "big picture" without having to constantly switch between different tabs or windows.
Here is how the logic flows:
- Timeframe Synchronization: The script allows you to select a specific master timeframe (ranging from 1 minute up to monthly views). It compares your current chart against this selected period. If your current chart is faster than the chosen timeframe, the tool provides a notification to ensure you are viewing the data correctly.
- Data Retrieval: The logic identifies the corresponding historical data points for the chosen timeframe. It essentially "maps" the large blocks of time onto the smaller bars you see on your screen.
- Trend Visualization: The script utilizes a specific calculation method (Heiken Ashi) to generate two distinct visual components:
- Buffer 1: Represents one aspect of the trend movement, plotted as a histogram.
- Buffer 2: Represents a secondary trend component, also plotted as a histogram.
- Visual Interpretation: By presenting these two data points as histograms in a separate window, the tool helps traders distinguish between different phases of market momentum. It simplifies complex price movements into a visual representation of strength and direction.
Summary for the Trader
In simple terms, this script acts as a "macro lens." While you might be looking at individual candles moving up and down quickly, Range_v2 overlays the trend of a much larger timeframe on top of your current view. This helps ensure that your trades are aligned with the dominant market direction, reducing the risk of trading against a powerful long-term trend.
//+------------------------------------------------------------------+
//| Range_v2.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 Red
#property indicator_width1 3
#property indicator_color2 White
#property indicator_width2 3
#property indicator_maximum 1.05
#property indicator_minimum -0.05
extern int TimeFrame=1440;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int init()
{
string short_name;
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
short_name="HeikenAshiSW("+TimeFrame+")";
IndicatorShortName(short_name);
switch(TimeFrame)
{
case 1 : TimeFrame=PERIOD_M1; break;
case 5 : TimeFrame=PERIOD_M5; break;
case 15 : TimeFrame=PERIOD_M15; break;
case 30 : TimeFrame=PERIOD_M30; break;
case 60 : TimeFrame=PERIOD_H1; break;
case 240 : TimeFrame=PERIOD_H4; break;
case 1440 : TimeFrame=PERIOD_D1; break;
case 7200 : TimeFrame=PERIOD_W1; break;
case 28800: TimeFrame=PERIOD_MN1; break;
default : TimeFrame=Period(); break;
}
return(0);
}
int start()
{
datetime TimeArray[];
int i=0,y=0, prevy=0;
int counted_bars=IndicatorCounted();
if (TimeFrame<Period())
{
SetIndexDrawBegin(0,Bars);
SetIndexDrawBegin(1,Bars);
Comment("Incorrect TimeFrame");
return(0);
}
if ( counted_bars > 0 ) int limit=Bars-counted_bars;
if ( counted_bars < 0 ) return(0);
if ( counted_bars ==0 ) limit=Bars-1;
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"Heiken Ashi_SW",0,y) ;
ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"Heiken Ashi_SW",1,y) ;
}
return(0);
}
Comments