//+------------------------------------------------------------------+ 
//| LGP-Pivot DJ-2 (ëåîíèä).mq4 | 
//| Copyright © 2006, MetaQuotes Software Corp. | 
//| http://www.metaquotes.net | 
//+------------------------------------------------------------------+ 

//+------------------------------------------------------------------+ 
//| 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); 
} 
//+------------------------------------------------------------------+ 

