LGP-Pivot DJ
Download scriptThis script is designed to automatically calculate and display specific market price levels—known as Pivot Points—based on the trading activity of two major global regions: Europe and the USA. Instead of requiring you to manually scan charts to find significant highs, lows, and averages, the tool performs these calculations in the background and displays the results directly on your screen.
How it Works
The logic follows a structured process to identify key price benchmarks for both market sessions:
1. Data Collection The script monitors the 5-minute price candles of your current asset. It specifically looks for historical data points including the opening price, the highest price reached (High), the lowest price reached (Low), and the closing price for each period.
2. Regional Time Windowing The tool is programmed to recognize two distinct "calculation windows" based on user-defined hours:
- Europe Session: It identifies a specific timeframe related to European trading activity.
- USA Session: It identifies a separate timeframe related to American trading activity.
3. Automated Calculation For both the Europe and USA sessions, the script performs three simultaneous actions:
- It scans the price history within the designated time window to find the absolute highest price and the absolute lowest price.
- It captures the closing price at a specific point in time.
- It applies the standard Pivot Point formula: adding the High, the Low, and the Close together, then dividing by three.
4. Real-Time Display Once the calculations are complete, the script clears previous information and updates your chart display with a summary. You will see a clear text readout showing:
- The calculated Pivot Point for both regions.
- The specific High, Low, and Close prices that were used to generate those pivots.
Summary for the Trader
Essentially, this tool acts as a data aggregator. It takes "raw" price action from the European and American markets and distills it into three key numbers (Pivot, High, and Low). This allows you to quickly see where the major price boundaries were established during those specific sessions without having to manually calculate the math or search through past candles.
//+------------------------------------------------------------------+
//| LGP-Pivot DJ-2 |
//| Copyright © 2005, LGP |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
// 17-10-05
// 17-11-05
#property copyright "Copyright © 2005, LGP"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 1
//---- input parameters
extern double forEurope_periodRascheta_hour=9;
extern double forUSA_periodRascheta_hour=6;
extern double forEurope_end_hourMT4=7;
extern double forEurope_end_minuteMT4=15;
extern double forUSA_end_hourMT4=13;
extern double forUSA_end_minuteMT4=0;
//
double nClose=0;
double nPivot=0;
double nMaxHigh=0;
double nMinLow=99999999;
//---- buffers
//
double mas[][6];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
Comment (" ");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Comment (" ");
return(0);
}
//------------------------------------------------------------------
void funPivot(double PeriodHour, double hourMT4, double minuteMT4)
{
//
nPivot=0;
nMaxHigh=0;
nMinLow=99999999;
nClose=0;
//
string sTimeMT4=DoubleToStr(Year(),0)+"."+DoubleToStr(Month(),0)+"."+DoubleToStr(Day(),0)+" "
+ DoubleToStr(hourMT4,0)+":"+DoubleToStr(minuteMT4,0)+":00";
datetime dTimeMT4=StrToTime(sTimeMT4);
//
int k=0;
int n=3000;
for (int i=0; i<n; i++)
{
if (mas[i][0]==dTimeMT4)
{
k=i;
break;
}
}
if (k==0)
return(1);
//
int m=(PeriodHour *12)+(minuteMT4/5);
//
for (i=k; i<=(k+m); i++)
{
if (mas[i][2]<nMinLow) nMinLow=mas[i][2]; //low
if (mas[i][3]>nMaxHigh) nMaxHigh=mas[i][3]; //High
}
//
nClose=mas[k][4]; //Close
nPivot=(nMaxHigh+nMinLow+nClose)/3;
//
return(0);
}
int start()
{
/* double mas1[][6];
ArrayCopyRates(mas1,Symbol(), PERIOD_M1);
0 - time,
1 - open,
2 - low,
3 - high,
4 - close,
5 - volume.
*/
ArrayCopyRates(mas,Symbol(), PERIOD_M5); //M5
//----------------------------------------------
double PeriodHour_ = forEurope_periodRascheta_hour;
double hourMT4_ = forEurope_end_hourMT4;
double minuteMT4_ = forEurope_end_minuteMT4;
//
funPivot(PeriodHour_, hourMT4_, minuteMT4_);
//
double nPivotEurope = nPivot;
double nMaxHighE = nMaxHigh;
double nMinLowE = nMinLow;
double nCloseE = nClose;
//----------------------------------------------
PeriodHour_ = forUSA_periodRascheta_hour;
hourMT4_ = forUSA_end_hourMT4;
minuteMT4_ = forUSA_end_minuteMT4;
//
funPivot(PeriodHour_, hourMT4_, minuteMT4_);
//
double nPivotUSA = nPivot;
double nMaxHighU = nMaxHigh;
double nMinLowU = nMinLow;
double nCloseU = nClose;
//
if (nPivotEurope!=0 && nPivotUSA!=0 )
Comment( "\n","PivotEurope=",nPivotEurope,
", ","High=",nMaxHighE,
", ","Low=",nMinLowE,
", ","Close=",nCloseE,
"\n","PivotUSA =",nPivotUSA,
", ","High=",nMaxHighU,
", ","Low=",nMinLowU,
", ","Close=",nCloseU);
else
if (nPivotEurope!=0)
Comment( "\n","PivotEurope=",nPivotEurope,
" ","High=",nMaxHighE,
" ","Low=",nMinLowE,
", ","Close=",nCloseE);
return(0);
}
//+------------------------------------------------------------------+
Comments