
// FOR THOSE OF YOU THAT IMPROVE UPON THIS HERE CODE I ASK YOU ONE THING
// PLEASE POST A COPY UP ON THE FOREX FORUMS FOR YOUR FELLOW TRADERS

#property indicator_chart_window

#property indicator_minimum 0
#property indicator_maximum 1

//---- Positionning the boxs
extern string    Which_Corner_for_all  = "=== Select corner. 0=Upper Left, 1=Upper Right, 2=lower left , 3=lower right ===";
extern int       Global_Corner         =     3;

extern string    Trade_info_box            = "=== Trade Info Box ===";
extern bool      box_trade_analysis    =   false;
extern int       X_trade_analysis      =      10;
extern int       Y_analysis            =      20;


extern string    Pivots_box            = "=== Pivots Box ===";
extern bool      box_pivots            =   false;
extern int       X_pivots              =      17;
extern int       Y_pivots              =     200;

extern string    Range_box             = "=== Range Box ===";
extern bool      box_range             =    true;
extern int       X_range               =      15;
extern int       Y_range               =      6;


//---- Level to change the strength "weak" to "strong"
extern double TrendStrongLevel = 75.00;

//---- Indicators parameters
extern string    Shift_Settings_test_only        = "=== Format: 2007.05.07 00:00 ===";
extern datetime  look_time_shift       = D'2007.05.07 00:00';  // Shift for test if "test" is true
extern double    shift_indicators      =                   0;  // Shift for indicators if "test" is false
extern bool      test                  =               false;

int TimeZone=0, win=0;
bool pivots = true;
bool alert = true;

double yesterday_high=0;
double yesterday_open=0;
double yesterday_low=0;
double yesterday_close=0;
double today_open=0;
double today_high=0;
double today_low=0;

double rates_h1[2][6];
double rates_d1[2][6];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {



//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----


   ObjectDelete("timeframe");
   ObjectDelete("pivots");
   ObjectDelete("R3_Label");
   ObjectDelete("R3_Value");
   ObjectDelete("R2_Label");
   ObjectDelete("R2_Value");
   ObjectDelete("R1_Label");
   ObjectDelete("R1_Value");
   ObjectDelete("Pivot_Label");
   ObjectDelete("Pivot_Value");
   ObjectDelete("S1_Label");
   ObjectDelete("S1_Value");
   ObjectDelete("S2_Label");
   ObjectDelete("S2_Value");
   ObjectDelete("S3_Label");
   ObjectDelete("S3_Value");
   ObjectDelete("daily_range");
   ObjectDelete("ZZPANEL-line6");
   ObjectDelete("ZZPANEL-today");
   ObjectDelete("ZZPANEL-today_range");
   ObjectDelete("ZZPANEL-yesterday");
   ObjectDelete("ZZPANEL-yesterday_range");
   ObjectDelete("ZZPANEL-5_days");
   ObjectDelete("ZZPANEL-5_days_range");
   ObjectDelete("ZZPANEL-10_days");
   ObjectDelete("ZZPANEL-10_days_range");
   ObjectDelete("ZZPANEL-20_days");
   ObjectDelete("ZZPANEL-20_days_range");
   ObjectDelete("ZZPANEL-50_days");
   ObjectDelete("ZZPANEL-50_days_range");
   ObjectDelete("ZZPANEL-line7");
   ObjectDelete("ZZPANEL-Average");
   ObjectDelete("ZZPANEL-Average_range");
   ObjectDelete("ZZPANEL-line8");
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {  
     
   if( box_trade_analysis == true )
   {
   
//---- Timeframe and symbol

   string Timeframe = "";
   color color_timeframe=SkyBlue;
   
   double time_frame=Period();
   string symbol=Symbol();
   
   if(time_frame==1) { Timeframe = "M1"; }
   if(time_frame==5) { Timeframe = "M5"; }
   if(time_frame==15) { Timeframe = "M15"; }
   if(time_frame==30) { Timeframe = "M30"; }
   if(time_frame==60) { Timeframe = "H1"; }
   if(time_frame==240) { Timeframe = "H4"; }
   if(time_frame==1440) { Timeframe = "D1"; }
   if(time_frame==10080) { Timeframe = "W1"; }
   if(time_frame==43200) { Timeframe = "MN"; }
   
   int Xdist_timeframe, Ydist_timeframe;
   int Xdist_line;
   int Ydist_line1, Ydist_line2, Ydist_line3, Ydist_line4;
   int Xdist_text;
   int Xdist_value;
   int Xdist_stoploss, Ydist_stoploss, Ydist_stop;
   int Xdist_pipstostop, Ydist_pipstostop, Ydist_pipsstop;
   int Xdist_pipsprofit, Ydist_pipsprofit, Ydist_pips_profit;
   int Xdist_percentbalance, Ydist_percentbalance, Ydist_percent_profit;
   int Xdist_maxlot1, Ydist_maxlot1, Ydist_maxlot2;
    
    Xdist_timeframe = 10 + X_trade_analysis; Ydist_timeframe = 15 + (Y_analysis-15);
    Xdist_line = 2 + X_trade_analysis;
    Ydist_line1 = 27 + (Y_analysis-15); Ydist_line2 = 77 + (Y_analysis-15); Ydist_line3 = 117 + (Y_analysis-15); Ydist_line4= 140 + (Y_analysis-15);
    Xdist_text = 3 + X_trade_analysis;
    Xdist_value = 92 + X_trade_analysis;
    Ydist_stoploss = 43 + (Y_analysis-15); Ydist_stop = 43 + (Y_analysis-15);
    Ydist_pipstostop = 62 + (Y_analysis-15); Ydist_pipsstop = 62 + (Y_analysis-15);
    Ydist_pipsprofit = 88 + (Y_analysis-15); Ydist_pips_profit = 88 + (Y_analysis-15);
    Ydist_percentbalance = 106 + (Y_analysis-15); Ydist_percent_profit = 106 + (Y_analysis-15);
    Ydist_maxlot1 = 129 + (Y_analysis-15); Ydist_maxlot2 = 129 + (Y_analysis-15);
    
}  
   
// Shift calculation for indicators (tests only)

   double shift_1, shift_5, shift_15, shift_30, shift_60, shift_240, shift_1440, shift_10080;
   
   if( test == true )
   {
    shift_1=iBarShift(NULL,PERIOD_M1,look_time_shift,false);
    shift_5=iBarShift(NULL,PERIOD_M5,look_time_shift,false);
    shift_15=iBarShift(NULL,PERIOD_M15,look_time_shift,false);
    shift_30=iBarShift(NULL,PERIOD_M30,look_time_shift,false);
    shift_60=iBarShift(NULL,PERIOD_H1,look_time_shift,false);
    shift_240=iBarShift(NULL,PERIOD_H4,look_time_shift,false);
    shift_1440=iBarShift(NULL,PERIOD_D1,look_time_shift,false);
    shift_10080=iBarShift(NULL,PERIOD_W1,look_time_shift,false);
   }
   else
   {
    shift_1=shift_indicators;
    shift_5=shift_indicators;
    shift_15=shift_indicators;
    shift_30=shift_indicators;
    shift_60=shift_indicators;
    shift_240=shift_indicators;
    shift_1440=shift_indicators;
    shift_10080=shift_indicators;
   }
   
   
   
// DAILY PIVOTS AND RANGE
   
//---- Get new daily prices

   ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);
   
//---- modifs ibfx
   int offset = 0;
   if(DayOfWeek()==1) offset=1;
//----

   double day50_high = rates_d1[50+offset][3];
   double day50_low = rates_d1[50+offset][2]; 
   double day49_high = rates_d1[49+offset][3];
   double day49_low = rates_d1[49+offset][2]; 
   double day48_high = rates_d1[48+offset][3];
   double day48_low = rates_d1[48+offset][2]; 
   double day47_high = rates_d1[47+offset][3];
   double day47_low = rates_d1[47+offset][2]; 
   double day46_high = rates_d1[46+offset][3];
   double day46_low = rates_d1[46+offset][2]; 
   double day45_high = rates_d1[45+offset][3];
   double day45_low = rates_d1[45+offset][2]; 
   double day44_high = rates_d1[44+offset][3];
   double day44_low = rates_d1[44+offset][2]; 
   double day43_high = rates_d1[43+offset][3];
   double day43_low = rates_d1[43+offset][2]; 
   double day42_high = rates_d1[42+offset][3];
   double day42_low = rates_d1[42+offset][2]; 
   double day41_high = rates_d1[41+offset][3];
   double day41_low = rates_d1[41+offset][2]; 
   double day40_high = rates_d1[40+offset][3];
   double day40_low = rates_d1[40+offset][2]; 
   double day39_high = rates_d1[39+offset][3];
   double day39_low = rates_d1[39+offset][2]; 
   double day38_high = rates_d1[38+offset][3];
   double day38_low = rates_d1[38+offset][2]; 
   double day37_high = rates_d1[37+offset][3];
   double day37_low = rates_d1[37+offset][2]; 
   double day36_high = rates_d1[36+offset][3];
   double day36_low = rates_d1[36+offset][2]; 
   double day35_high = rates_d1[35+offset][3];
   double day35_low = rates_d1[35+offset][2]; 
   double day34_high = rates_d1[34+offset][3];
   double day34_low = rates_d1[34+offset][2]; 
   double day33_high = rates_d1[33+offset][3];
   double day33_low = rates_d1[33+offset][2]; 
   double day32_high = rates_d1[32+offset][3];
   double day32_low = rates_d1[32+offset][2]; 
   double day31_high = rates_d1[31+offset][3];
   double day31_low = rates_d1[31+offset][2]; 
   double day30_high = rates_d1[30+offset][3];
   double day30_low = rates_d1[30+offset][2]; 
   double day29_high = rates_d1[29+offset][3];
   double day29_low = rates_d1[29+offset][2]; 
   double day28_high = rates_d1[28+offset][3];
   double day28_low = rates_d1[28+offset][2]; 
   double day27_high = rates_d1[27+offset][3];
   double day27_low = rates_d1[27+offset][2]; 
   double day26_high = rates_d1[26+offset][3];
   double day26_low = rates_d1[26+offset][2]; 
   double day25_high = rates_d1[25+offset][3];
   double day25_low = rates_d1[25+offset][2]; 
   double day24_high = rates_d1[24+offset][3];
   double day24_low = rates_d1[24+offset][2]; 
   double day23_high = rates_d1[23+offset][3];
   double day23_low = rates_d1[23+offset][2]; 
   double day22_high = rates_d1[22+offset][3];
   double day22_low = rates_d1[22+offset][2]; 
   double day21_high = rates_d1[21+offset][3];
   double day21_low = rates_d1[21+offset][2]; 
   double day20_high = rates_d1[20+offset][3];
   double day20_low = rates_d1[20+offset][2]; 
   double day19_high = rates_d1[19+offset][3];
   double day19_low = rates_d1[19+offset][2]; 
   double day18_high = rates_d1[18+offset][3];
   double day18_low = rates_d1[18+offset][2]; 
   double day17_high = rates_d1[17+offset][3];
   double day17_low = rates_d1[17+offset][2]; 
   double day16_high = rates_d1[16+offset][3];
   double day16_low = rates_d1[16+offset][2]; 
   double day15_high = rates_d1[15+offset][3];
   double day15_low = rates_d1[15+offset][2]; 
   double day14_high = rates_d1[14+offset][3];
   double day14_low = rates_d1[14+offset][2]; 
   double day13_high = rates_d1[13+offset][3];
   double day13_low = rates_d1[13+offset][2]; 
   double day12_high = rates_d1[12+offset][3];
   double day12_low = rates_d1[12+offset][2]; 
   double day11_high = rates_d1[11+offset][3];
   double day11_low = rates_d1[11+offset][2]; 
   double day10_high = rates_d1[10+offset][3];
   double day10_low = rates_d1[10+offset][2]; 
   double day9_high = rates_d1[9+offset][3];
   double day9_low = rates_d1[9+offset][2];
   double day8_high = rates_d1[8+offset][3];
   double day8_low = rates_d1[8+offset][2]; 
   double day7_high = rates_d1[7+offset][3];
   double day7_low = rates_d1[7+offset][2]; 
   double day6_high = rates_d1[6+offset][3];
   double day6_low = rates_d1[6+offset][2]; 
   double day5_high = rates_d1[5+offset][3];
   double day5_low = rates_d1[5+offset][2]; 
   double day4_high = rates_d1[4+offset][3];
   double day4_low = rates_d1[4+offset][2]; 
   double day3_high = rates_d1[3+offset][3];
   double day3_low = rates_d1[3+offset][2]; 
   double day2_high = rates_d1[2+offset][3];
   double day2_low = rates_d1[2+offset][2]; 
   double yesterday_high = rates_d1[1+offset][3];
   double yesterday_low = rates_d1[1+offset][2];
   double yesterday_close = rates_d1[1+offset][4];
   double day_high = rates_d1[0][3];
   double day_low = rates_d1[0][2];
   
/*
   int i=0;

   ArrayCopyRates(rates_h1, Symbol(), PERIOD_H1);
   for (i=0;i<=25;i++)
   {
    if (TimeMinute(rates_h1[i][0])==0 && (TimeHour(rates_h1[i][0])-TimeZone)==0)
    {
     yesterday_close = rates_h1[i+1][4];      
     yesterday_open = rates_h1[i+24][1];
     today_open = rates_h1[i][1];      
     break;
    }
   }
*/

//---- Calculate Pivots et range

   double D = (day_high - day_low);
   double Q = (yesterday_high - yesterday_low);
   double Q2 = (day2_high - day2_low);
   double Q3 = (day3_high - day3_low);
   double Q4 = (day4_high - day4_low);
   double Q5 = (day5_high - day5_low);
   double Q6 = (day6_high - day6_low);
   double Q7 = (day7_high - day7_low);
   double Q8 = (day8_high - day8_low);
   double Q9 = (day9_high - day9_low);
   double Q10 = (day10_high - day10_low);
   double Q11 = (day11_high - day11_low);
   double Q12 = (day12_high - day12_low);
   double Q13 = (day13_high - day13_low);
   double Q14 = (day14_high - day14_low);
   double Q15 = (day15_high - day15_low);
   double Q16 = (day16_high - day16_low);
   double Q17 = (day17_high - day17_low);
   double Q18 = (day18_high - day18_low);
   double Q19 = (day19_high - day19_low);
   double Q20 = (day20_high - day20_low);
   double Q21 = (day21_high - day21_low);
   double Q22 = (day22_high - day22_low);
   double Q23 = (day23_high - day23_low);
   double Q24 = (day24_high - day24_low);
   double Q25 = (day25_high - day25_low);
   double Q26 = (day26_high - day26_low);
   double Q27 = (day27_high - day27_low);
   double Q28 = (day28_high - day28_low);
   double Q29 = (day29_high - day29_low);
   double Q30 = (day30_high - day30_low);
   double Q31 = (day31_high - day31_low);
   double Q32 = (day32_high - day32_low);
   double Q33 = (day33_high - day33_low);
   double Q34 = (day34_high - day34_low);
   double Q35 = (day35_high - day35_low);
   double Q36 = (day36_high - day36_low);
   double Q37 = (day37_high - day37_low);
   double Q38 = (day38_high - day38_low);
   double Q39 = (day39_high - day39_low);
   double Q40 = (day40_high - day40_low);
   double Q41 = (day41_high - day41_low);
   double Q42 = (day42_high - day42_low);
   double Q43 = (day43_high - day43_low);
   double Q44 = (day44_high - day44_low);
   double Q45 = (day45_high - day45_low);
   double Q46 = (day46_high - day46_low);
   double Q47 = (day47_high - day47_low);
   double Q48 = (day48_high - day48_low);
   double Q49 = (day49_high - day49_low);
   double Q50 = (day50_high - day50_low);
   double P = (yesterday_high + yesterday_low + yesterday_close) / 3;
   double R1 = (2*P)-yesterday_low;
   double S1 = (2*P)-yesterday_high;
   double R2 = P+(R1 - S1);
   double S2 = P-(R1 - S1);
	double R3 = (2*P)+(yesterday_high-(2*yesterday_low));
	double S3 = (2*P)-((2* yesterday_high)-yesterday_low);
	
	
	
	
	
	int Precision, dig;
{
/*        if(StringFind  (Symbol(), "JPY", 0) != -1)  DecNos = 2;
   else if(StringSubstr(Symbol(),0,6) == "XAUUSD")  DecNos = 1;
   else if(StringSubstr(Symbol(),0,6) == "XAGUSD")  DecNos = 2;
   else if(StringSubstr(Symbol(),0,6) == "USDMXN")  DecNos = 3;
   else if(StringSubstr(Symbol(),0,6) == "GBPSEK")  DecNos = 3;
   else if(StringSubstr(Symbol(),0,6) == "GOOGNY")  DecNos = 2;
   else if(StringSubstr(Symbol(),0,6) == "UK100")   DecNos = 2;
   else                                             DecNos = 4;
*/

        if( StringFind( Symbol(), "XAU", 0) != -1 ) { Precision =    10;     dig = 1; }
   else if( StringFind( Symbol(), "JPY", 0) != -1 ) { Precision =   100;     dig = 2; }
   else if( StringFind( Symbol(), "SPI", 0) != -1 ) { Precision =    10;     dig = 1; }
   else if( StringFind( Symbol(), "SP5", 0) != -1 ) { Precision =    10;     dig = 1; }
   else if( StringFind( Symbol(), "DJ3", 0) != -1 ) { Precision =    10;     dig = 1; }
   else if( StringFind( Symbol(), "XAG", 0) != -1 ) { Precision =   100;     dig = 2; }            
   else if( StringFind( Symbol(), "FTS", 0) != -1 ) { Precision =    10;     dig = 1; }
   else if( StringFind( Symbol(), "DAX", 0) != -1 ) { Precision =    10;     dig = 1; }   
   else                                             { Precision = 10000;     dig = 4; }
} 
	double D0 = D * Precision;
	double Q0 = Q * Precision;
	double Q5_av = ((Q + Q2 + Q3 + Q4 + Q5) / 5) * Precision;
	double Q10_av = ((Q + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9 + Q10) / 10) * Precision;
	double Q20_av = ((Q + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9
	                 + Q10 + Q11 + Q12 + Q13 + Q14 + Q15 + Q16 + Q17 + Q18 + Q19 + Q20) / 20) * Precision;
	/*
	double Q30_av = ((Q + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9
	                 + Q10 + Q11 + Q12 + Q13 + Q14 + Q15 + Q16 + Q17 + Q18 + Q19
	                 + Q20 + Q21 + Q22 + Q23 + Q24 + Q25 + Q26 + Q27 + Q28 + Q29 + Q30) / 30) * Precision;
	double Q40_av = ((Q + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9
	                 + Q10 + Q11 + Q12 + Q13 + Q14 + Q15 + Q16 + Q17 + Q18 + Q19
	                 + Q20 + Q21 + Q22 + Q23 + Q24 + Q25 + Q26 + Q27 + Q28 + Q29
	                 + Q30 + Q31 + Q32 + Q33 + Q34 + Q35 + Q36 + Q37 + Q38 + Q39 + Q40) / 40) * Precision;
	*/
	double Q50_av = ((Q + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9
	                 + Q10 + Q11 + Q12 + Q13 + Q14 + Q15 + Q16 + Q17 + Q18 + Q19
	                 + Q20 + Q21 + Q22 + Q23 + Q24 + Q25 + Q26 + Q27 + Q28 + Q29
	                 + Q30 + Q31 + Q32 + Q33 + Q34 + Q35 + Q36 + Q37 + Q38 + Q39
	                 + Q40 + Q41 + Q42 + Q43 + Q44 + Q45 + Q46 + Q47 + Q48 + Q49 + Q50) / 50) * Precision;
	
	double average_range = (Q0 + Q5_av + Q10_av + Q20_av + Q50_av) / 5;
	
	
//---- Set Pivots labels

   if( box_pivots == true )
   {
   int Ydist_line5;
   int Xdist_pivots, Ydist_pivots;
   int Ydist_R3, Ydist_R2, Ydist_R1, Ydist_PV, Ydist_S1, Ydist_S2, Ydist_S3;
   color color_pivots_1=PaleVioletRed;
   
    Xdist_line = 1010+(X_pivots-1000); Xdist_text = 1013+(X_pivots-1000); Xdist_value = 1050+(X_pivots-1000);
    Ydist_line5 = 16+(Y_pivots-5);
    Xdist_pivots = 1010+(X_pivots-1000); Ydist_pivots = 5+(Y_pivots-5);
    Ydist_R3 = 30+(Y_pivots-5); Ydist_R2 = 45+(Y_pivots-5); Ydist_R1 = 60+(Y_pivots-5); Ydist_PV = 75+(Y_pivots-5); Ydist_S1 = 90+(Y_pivots-5); Ydist_S2 = 105+(Y_pivots-5); Ydist_S3 = 120+(Y_pivots-5);
      
   }   // if( box_pivots == true )
   
   
   
// DAILY RANGE

   if( box_range == true )
   {

   int Ydist_line6, Ydist_line7, Ydist_line8;
   int Corner_range, Xdist_range, Ydist_range;
   int Ydist_today, Ydist_yesterday, Ydist_5, Ydist_10, Ydist_20, Ydist_50;
   int Ydist_average;
  
    Xdist_line = 1121+(X_range-1115); Xdist_text = 1124+(X_range-1115); Xdist_value = 1185+(X_range-1115);
    Ydist_line6 = 16+(Y_range-5); Ydist_line7 = 112+(Y_range-5); Ydist_line8 = 127+(Y_range-5);
    Corner_range = 1; Xdist_range = 1120+(X_range-1115); Ydist_range = 5+(Y_range-5);
    Ydist_today = 28+(Y_range-5); Ydist_yesterday = 42+(Y_range-5); Ydist_5 = 57+(Y_range-5); Ydist_10 = 72+(Y_range-5); Ydist_20 = 87+(Y_range-5); Ydist_50 = 102+(Y_range-5); Ydist_average = 118+(Y_range-5);
  
/*   ObjectCreate("daily_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("daily_range","+Daily Range+",9, "Verdana", Silver);
   ObjectSet("daily_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("daily_range", OBJPROP_XDISTANCE, Xdist_range);
   ObjectSet("daily_range", OBJPROP_YDISTANCE, Ydist_range);
*/   
   
   ObjectCreate("ZZPANEL-today", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-today","Today",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-today", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-today", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-today", OBJPROP_YDISTANCE, 132+Y_range);//Ydist_today);
   
   ObjectCreate("ZZPANEL-today_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-today_range",DoubleToStr(D0,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-today_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-today_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-today_range", OBJPROP_YDISTANCE, 133+Y_range);//Ydist_today);
   
   ObjectCreate("ZZPANEL-yesterday", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-yesterday","1 Day",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-yesterday", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-yesterday", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-yesterday", OBJPROP_YDISTANCE, 112+Y_range);//Ydist_yesterday);
   
   ObjectCreate("ZZPANEL-yesterday_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-yesterday_range",DoubleToStr(Q0,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-yesterday_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-yesterday_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-yesterday_range", OBJPROP_YDISTANCE, 112+Y_range);//Ydist_yesterday);
   
   ObjectCreate("ZZPANEL-5_days", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-5_days","5 Days",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-5_days", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-5_days", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-5_days", OBJPROP_YDISTANCE, 96+Y_range);//Ydist_5);
   
   ObjectCreate("ZZPANEL-5_days_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-5_days_range",DoubleToStr(Q5_av,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-5_days_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-5_days_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-5_days_range", OBJPROP_YDISTANCE, 96+Y_range);//Ydist_5);
   
   ObjectCreate("ZZPANEL-10_days", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-10_days","10 Days",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-10_days", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-10_days", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-10_days", OBJPROP_YDISTANCE, 80+Y_range);//Ydist_10);
   
   ObjectCreate("ZZPANEL-10_days_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-10_days_range",DoubleToStr(Q10_av,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-10_days_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-10_days_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-10_days_range", OBJPROP_YDISTANCE, 80+Y_range);//Ydist_10);
   
   ObjectCreate("ZZPANEL-20_days", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-20_days","20 Days",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-20_days", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-20_days", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-20_days", OBJPROP_YDISTANCE, 64+Y_range);//Ydist_20);
   
   ObjectCreate("ZZPANEL-20_days_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-20_days_range",DoubleToStr(Q20_av,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-20_days_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-20_days_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-20_days_range", OBJPROP_YDISTANCE, 64+Y_range);//Ydist_20);
   
   ObjectCreate("ZZPANEL-50_days", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-50_days","50 Days",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-50_days", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-50_days", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-50_days", OBJPROP_YDISTANCE, 48+Y_range);//Ydist_50);
   
   ObjectCreate("ZZPANEL-50_days_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-50_days_range",DoubleToStr(Q50_av,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-50_days_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-50_days_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-50_days_range", OBJPROP_YDISTANCE, 48+Y_range);//Ydist_50);
   
   ObjectCreate("ZZPANEL-line6", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-line6","------------------",8, "Verdana", Silver);
   ObjectSet("ZZPANEL-line6", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-line6", OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet("ZZPANEL-line6", OBJPROP_YDISTANCE, 38+Y_range);

   ObjectCreate("ZZPANEL-line7", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-line7","------------------",8, "Verdana", Silver);
   ObjectSet("ZZPANEL-line7", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-line7", OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet("ZZPANEL-line7", OBJPROP_YDISTANCE, 122+Y_range);//Ydist_line7+2);
   
   ObjectCreate("ZZPANEL-Average", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-Average","Average",9, "Verdana", Silver);
   ObjectSet("ZZPANEL-Average", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-Average", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("ZZPANEL-Average", OBJPROP_YDISTANCE, 28+Y_range);//Ydist_average+6);
   
   ObjectCreate("ZZPANEL-Average_range", OBJ_LABEL, win, 0, 0);
   ObjectSetText("ZZPANEL-Average_range",DoubleToStr(average_range,0),9, "Verdana", Silver);
   ObjectSet("ZZPANEL-Average_range", OBJPROP_CORNER, Global_Corner);
   ObjectSet("ZZPANEL-Average_range", OBJPROP_XDISTANCE, Xdist_value);
   ObjectSet("ZZPANEL-Average_range", OBJPROP_YDISTANCE, 28+Y_range);// Ydist_average+6);
      
   }   // if( box_range == true )
   
      
   return(0);
  }