Author: Copyright � 2007, zIG
zIG_DBO

This tool is designed to help traders visualize price action by identifying key structural levels and volatility-based boundaries on a trading chart. Rather than relying on standard moving averages or oscillators, it focuses on the relationship between daily price ranges and current market extremes.

Core Functionality

1. Volatility Analysis The script begins by analyzing historical data to determine the typical "movement range" of the currency pair. It specifically looks at the difference between the highest and lowest prices over several timeframes (covering the last 5, 10, and 20 days). By averaging these various ranges together, the tool establishes a reliable baseline for how much the market typically moves in a single day.

2. Dynamic Support and Resistance Calculation Once the average volatility is established, the script creates two primary visual boundaries:

  • Upper Boundary (J1): This line tracks the highest price reached during the current trading session. It then subtracts a portion of the calculated average volatility from that peak to project a dynamic resistance level.
  • Lower Boundary (B1): Conversely, this tracks the lowest price reached in the session and adds a portion of the average volatility to it, projecting a dynamic support level.

3. Daily Session Tracking The script is intelligent enough to recognize when a new day begins on the market calendar. When a day change occurs, it resets its internal tracking variables. This ensures that the boundaries are always relevant to the current day's price action rather than being skewed by data from previous days.

4. Visual Aids and Reference Points

  • Session Opening: The tool identifies the opening price of the daily candle, providing a clear reference point for where the current trading day started.
  • Weekend Markers: To enhance chart readability, the script automatically detects weekends (Saturdays and Sundays) and marks them with distinct background colors. This helps traders quickly identify periods of market closure or low liquidity.

How it Helps the Trader

Instead of looking at static lines that never move, this script provides "breathing" boundaries. Because the support and resistance levels are calculated based on the actual average volatility of the asset, they adapt automatically to different market conditions—expanding during high-volatility periods and tightening during calmer markets. This helps in identifying potential reversal zones or breakout points based on how much "room" the market usually has to move.

Price Data Components
Series array that contains open time of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each bar
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
zIG_DBO

#property copyright "Copyright © 2007, zIG"
#property link      "http://www.wm-joker.ru"

#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  Snow
#property indicator_width1 0
#property indicator_color2  Red
#property indicator_width2 2
#property indicator_color3  Blue
#property indicator_width3 2


//---- buffers
double PBuffer[];
double J1Buffer[];
double B1Buffer[];
double J2Buffer[];
double B2Buffer[];
double J3Buffer[];
double B3Buffer[];
double P, J1, B1, J2, B2, J3, B3;
double LastHigh, LastLow, x;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{

ObjectsDeleteAll();
	//----
	return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
	//---- indicator line
	SetIndexStyle(0, DRAW_LINE);
	SetIndexStyle(1, DRAW_LINE);
	SetIndexStyle(2, DRAW_LINE);
	SetIndexBuffer(0, PBuffer);
	SetIndexBuffer(1, J1Buffer);
	SetIndexBuffer(2, B1Buffer);

	SetIndexDrawBegin(0,1);
	IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
	

int clr;
int q;
for(q=1;q<100;q++)
{
   clr=0;
   if(TimeDayOfWeek(iTime(NULL,1440,q))==5)clr=C'0,0,120';
   if(TimeDayOfWeek(iTime(NULL,1440,q))==1)clr=C'0,120,0';
   if(clr!=0)
   {
   ObjectCreate("B"+q, OBJ_RECTANGLE, 0, iTime(NULL,1440,q), iHigh(NULL,1440,q), iTime(NULL,1440,q-1), iLow(NULL,1440,q-1));
   ObjectSet("B"+q, OBJPROP_COLOR, clr);
   ObjectSet("B"+q,OBJPROP_BACK,true);
   ObjectSet("B"+q,OBJPROP_WIDTH,0);
   ObjectSet("B"+q,OBJPROP_STYLE,0);
   }
}

	//----
	return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
	int counted_bars = IndicatorCounted();
	int limit, i,currday,k=0;
	double op,lastlow=0,lasthigh=0,bl,sl;
   int      R1=0,R5=0,R10=0,R20=0,RAvg=0;



	if(counted_bars == 0)
	{
		x = Period();
		if(x > 240) 
			return(-1);


	}
	if(counted_bars < 0) 
		return(-1);

	limit = (Bars - counted_bars) - 1;

	for(i = limit; i >= 0; i--)
	{ 


		if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
		{
		   J1Buffer[i+1] = EMPTY_VALUE;
		   B1Buffer[i+1] = EMPTY_VALUE;
		   J1Buffer[i-1] = EMPTY_VALUE;
		   B1Buffer[i-1] = EMPTY_VALUE;
 

 R1=0;
 R5=0;
 R10=0;
 R20=0;
 RAvg=0;
		   currday=MathFloor(i*Period()/1440);
   R1 =  (iHigh(NULL,PERIOD_D1,currday+1)-iLow(NULL,PERIOD_D1,currday+1))/Point;
   for(k=1;k<=5;k++)    R5    =  R5  +  (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;
   for(k=1;k<=10;k++)   R10   =  R10 +  (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;
   for(k=1;k<=20;k++)   R20   =  R20 +  (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;


   R5    = R5/5;
   R10   = R10/10;
   R20   = R20/20;
   RAvg  =  (R5+R10+R20)/3;    
		   
			op=iOpen(NULL,PERIOD_D1,currday);
			lasthigh=High[i];
			lastlow=Low[i];
			
		}

  		if(High[i+1] > lasthigh)
  		{
			lasthigh = High[i+1];
			}
			J1=lasthigh-RAvg/2*Point;
			
		//----
		if(Low[i+1] < lastlow)
		{
			lastlow=Low[i+1];
         }
			B1=lastlow+RAvg/2*Point;
			
		J1Buffer[i] = J1;
		B1Buffer[i] = B1;
		PBuffer[i]=op;




	}

	//----
	return(0);

}
//+------------------------------------------------------------------+

Comments