Time Zone Pivots

Download script
Author: Copyright � 2005, Denis Manigart
Time Zone Pivots

This tool is designed to automate the calculation and visual mapping of "Pivot Points" on your trading charts. Pivot points are essential technical analysis levels used by traders to identify potential support (where price may stop falling) and resistance (where price may stop rising) based on previous market activity.

How the Logic Works

The script functions by analyzing historical price data—specifically the High, Low, and Close prices from the preceding trading session. It then uses these figures to project several key price levels for the current day.

Timezone Synchronization One of the core features of this script is its ability to handle specific time zones. By adjusting a single input setting, you can align the calculations with 0 GMT (Greenwich Mean Time) or any other offset relevant to your preferred data feed. This ensures that the "Daily" levels are calculated accurately regardless of where your local clock is set.

The Calculation Process The script automatically scans for the start of a new trading day. Once it identifies this transition, it performs a series of mathematical operations:

  • The Pivot Point: It calculates the average of the previous day's High, Low, and Close prices to establish the central "equilibrium" price for the current session.
  • Support and Resistance Levels (R1, S1, R2, S2): Using the central Pivot Point as a base, the script derives four additional levels. These represent the primary "boundaries" of the market.
    • Resistance levels (R) are calculated to show where sellers might enter the market to push prices down.
    • Support levels (S) are calculated to show where buyers might enter the market to push prices up.

Key Features for the Trader

  • Dynamic Mapping: The script automatically updates these levels as new days begin, ensuring your chart always reflects the most recent data available.
  • Visual Clarity: Instead of requiring you to calculate complex formulas manually, the script draws these levels directly on your chart window. This allows for a cleaner workspace where you can see at a glance where significant "walls" in price action are likely to occur.
  • Data Reference: Beyond just drawing lines, the script tracks and stores vital data points from the previous day—such as the exact closing price, high, and low—providing a consistent historical context for your current trading session.

In short, this tool removes the manual math from your routine, providing you with clear, automated visual markers of where market momentum is likely to face pressure based on yesterday's performance.

Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Time Zone Pivots
//+------------------------------------------------------------------+
//|                                              TimeZone Pivots.mq4 |
//|                                 Copyright © 2005, Denis Manigart |
//|                                     mailto:emaildomino@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Denis Manigart"
#property link      "mailto:emaildomino@gmail.com"

#property indicator_chart_window
#property indicator_buffers 8

#property indicator_color1 DarkOrange
#property indicator_color2 Khaki
#property indicator_color3 Khaki
#property indicator_color4 Khaki
#property indicator_color5 Khaki


#property indicator_color6 DarkViolet
#property indicator_color7 Blue
#property indicator_color8 Red
//#property indicator_color4 Gray

//---- input parameters
extern int TimeZoneOfData=2; // by default if time zone of data is at GMT +2
                             // This gives you the Pivot calculations for 0 GMT

//---- buffers
double PivotArray[];
double R1Array[];
double S1Array[];
double R2Array[];
double S2Array[];
double R3Array[];
double S3Array[];

double TodayOpenBuffer[];
double YesterdayCloseBuffer[];
double YesterdayHighBuffer[];
double YesterdayLowBuffer[];


//---- variables
int indexbegin = 0;
double todayopen = 0;
double yesterdayclose = 0;

double barhigh = 0;
double dayhigh = 0;
double yesterdayhigh = 0;

double barlow = 0;
double daylow = 0;
double yesterdaylow = 0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
	
	// Pivot
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PivotArray);
IndicatorShortName("TDPivot");
SetIndexLabel(0,"Pivot");
SetIndexEmptyValue(0, 0.0);
// Resistance 1
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,R1Array);
SetIndexLabel(1,"R1");
SetIndexEmptyValue(1, 0.0);
// Support 1
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,S1Array);
SetIndexLabel(2,"R1");
SetIndexEmptyValue(2, 0.0);
// Resistance 2
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,R2Array);
SetIndexLabel(3,"R2");
SetIndexEmptyValue(3, 0.0);
// Support 2
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,S2Array);
SetIndexLabel(4,"S2");
SetIndexEmptyValue(4, 0.0);

// You may also display the previous day close - high - low

// Daily Close	
//	SetIndexStyle(5, DRAW_LINE);
//	SetIndexBuffer(5, YesterdayCloseBuffer);
//	SetIndexLabel(5, "Daily Close");
//	SetIndexEmptyValue(5, 0.0);

// Daily High	
//	SetIndexStyle(6, DRAW_LINE);
//	SetIndexBuffer(6, YesterdayHighBuffer);
//	SetIndexLabel(6, "YesterDay High");
//	SetIndexEmptyValue(6, 0.0);	
	
// Daily Low	
//	SetIndexStyle(7, DRAW_LINE);
//	SetIndexBuffer(7, YesterdayLowBuffer);
//	SetIndexLabel(7, "YesterDay Low");
//	SetIndexEmptyValue(7, 0.0);
	

//----
	indexbegin = Bars - 20;
	if (indexbegin < 0)
		indexbegin = 0;
return(0);
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int i;
  
	int counted_bars = IndicatorCounted();
	
	
double Pivot;
double R1;
double S1;
double R2;
double S2;
	
	//---- check for possible errors
	if (counted_bars < 0) counted_bars = 0;
	//---- last counted bar will be recounted
	if (counted_bars > 0) counted_bars--;
	if (counted_bars > indexbegin) counted_bars = indexbegin;


		for (i = indexbegin-counted_bars; i >= 0; i--)
		{ 
		
		   if ( i == indexbegin-counted_bars) 
		       {
		        dayhigh = High[i];
		        daylow = Low[i];
		       }
		       
		       barlow = Low[i];	
				 barhigh = High[i];
				 
			if ( barhigh >= dayhigh) 
			    dayhigh = barhigh;	 		
			
			if ( barlow <= daylow) 
			    daylow = barlow;
		
//Cycle through all the bars and fill the indicator bars with the Pivot point values		   
		
			if ((TimeMinute(Time[i]) == 00) && (TimeHour(Time[i]) - TimeZoneOfData == 00))
				{todayopen = Open[i];
				 yesterdayclose = Close[i+1];
				 yesterdaylow = daylow;
				 daylow = Low [i]; // input new day value
				
				 yesterdayhigh = dayhigh;
				 dayhigh = High [i]; // input new day value
				
				Pivot = (yesterdayhigh + yesterdaylow + yesterdayclose)/3;
            R1 = (2*Pivot)-yesterdaylow;
            S1 = (2*Pivot)-yesterdayhigh;
            R2 = Pivot-S1+R1;
            S2 = Pivot-R1+S1;
				
				 }
				
				//These can be used for any calculations 
				TodayOpenBuffer[i] = todayopen;
				YesterdayCloseBuffer[i] = yesterdayclose;
				YesterdayHighBuffer[i] = yesterdayhigh;
				YesterdayLowBuffer[i] = yesterdaylow;
				
				
				
			   PivotArray[i]=Pivot;
            R1Array[i]=R1;
            S1Array[i]=S1;
            R2Array[i]=R2;
            S2Array[i]=S2;
			    

	}

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

Comments