 //+------------------------------------------------------------------+ 
//|   cm_WaterLevel_Above_Below                                      | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 

#property  copyright "Copyright © 2008, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpldone.com/" 

//---- indicator settings 
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1



//---- indicator parameters  
//extern int   Threshold       = 20; 

extern int win           = 0;
extern int price.x.offset= -500 ; //250
extern int price.y.offset= -160 ; //-160

extern int   Chart_Period    = PERIOD_H1;

extern int   MaxBars         = 24;

extern color ColorHeading    =  Gray ; 
extern color ColorRange      = LightGray ; 
extern color ThresholdColor  = LimeGreen; 
extern color ColorABAvg      =  DarkViolet ;    
extern color ColorAvg        =  Orange ;  
extern color ColorABCur      =  Blue ; 
extern color ColorMinMax      =  Chocolate ; 


//---- indicator buffers 


double     MaxRange = 0 ; 
double     MinRange = 0 ; 
double     AvgRange = 0 ; 
double     xRange   = 0 ; 
double     tRange   = 0 ; 



//---- buffers


double zRange = 0;

bool  show.info       = true;
bool  ShowChart       = true; 

double   AboveAvg, BelowAvg, AboveCur, BelowCur ;

double xRet, close ;
double xRetPct;  

extern string Time_Frame_value = "TimeFrame(0,M5,M15,M30,H1,H4,D1,W1,MN1)";
extern string Time_Frame       = "D1";

extern int Calculate_From_Previous_Bar = 0;
extern bool Show_BuySell_Price         = true;
extern bool Dynamic_BuySell_Price      = false;

extern bool Show_Magnified_WL_Price  = true;
extern int Magnified_WL_Price_Corner = 3;
extern string note2 = "Default Font Color";
extern color  FontColor              = SteelBlue;
extern string note3                  = "Font Size";
extern int FontSize                  = 14;
extern string note4                  = "Font Type";
extern string FontType               = "Tahoma";

extern bool Show_Comment = false;
extern bool Show_MAs     = false;

extern int Period_MA1 = 5;
extern int Period_MA2 = 7;
extern int Period_MA3 = 22;
extern int Period_MA4 = 34;

extern string MA_Type_value = "SMA, EMA, LWMA";
extern string MA_Type       = "SMA";

double TimeFrame1CloseAverageMA1, TimeFrame1CloseAverageMA2, TimeFrame1CloseAverageMA3, TimeFrame1CloseAverageMA4;
double TimeFrame2CloseAverageMA1, TimeFrame2CloseAverageMA2, TimeFrame2CloseAverageMA3, TimeFrame2CloseAverageMA4;

double TimeFrame1HighestHighMA1, TimeFrame1LowestLowMA1, TimeFrame2HighestHighMA1, TimeFrame2LowestLowMA1;
double TimeFrame1HighestHighMA2, TimeFrame1LowestLowMA2, TimeFrame2HighestHighMA2, TimeFrame2LowestLowMA2;
double TimeFrame1HighestHighMA3, TimeFrame1LowestLowMA3, TimeFrame2HighestHighMA3, TimeFrame2LowestLowMA3;
double TimeFrame1HighestHighMA4, TimeFrame1LowestLowMA4, TimeFrame2HighestHighMA4, TimeFrame2LowestLowMA4;

double TimeFrame1HighestHighAverage, TimeFrame1LowestLowAverage;
double TimeFrame2HighestHighAverage, TimeFrame2LowestLowAverage;

double TimeFrame1HHLLAverageMA1, TimeFrame2HHLLAverageMA1;
double TimeFrame1HHLLAverageMA2, TimeFrame2HHLLAverageMA2;
double TimeFrame1HHLLAverageMA3, TimeFrame2HHLLAverageMA3;
double TimeFrame1HHLLAverageMA4, TimeFrame2HHLLAverageMA4;

double TimeFrame1HHLLAverages, TimeFrame2HHLLAverages;
double TimeFrame2AverageMA1[], TimeFrame2AverageMA2[], TimeFrame2AverageMA3[], TimeFrame2AverageMA4[];

double TimeFrame1Level[], TimeFrame2Level[];
double SellPrice[], BuyPrice[];

int timeFrame1, timeFrame2, maType;
string TimeFrame1String, TimeFrame2String;

int lastBarTime = -1;
double lastBarClose = 0;
string InfoDisplay = "";


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
   
   if(Chart_Period == 0 ) { Chart_Period = Period() ;}
   
   

   if (Time_Frame == "M1") {

      timeFrame1 = PERIOD_M1;
      TimeFrame1String = "M1";

   } else if (Time_Frame == "M5") {

      timeFrame1 = PERIOD_M5;
      TimeFrame1String = "M5";

   } else if (Time_Frame == "M15") {

      timeFrame1 = PERIOD_M15;
      TimeFrame1String = "M15";

   } else if (Time_Frame == "M30") {

      timeFrame1 = PERIOD_M30;
      TimeFrame1String = "M30";

   } else if (Time_Frame == "H1") {

      timeFrame1 = PERIOD_H1;
      TimeFrame1String = "H1";

   } else if (Time_Frame == "H4") {

      timeFrame1 = PERIOD_H4;
      TimeFrame1String = "H4";

   } else if (Time_Frame == "D1") {

      timeFrame1 = PERIOD_D1;
      TimeFrame1String = "D1";

   } else if (Time_Frame == "W1") {

      timeFrame1 = PERIOD_W1;
      TimeFrame1String = "W1";

   } else if (Time_Frame == "MN1") {

      timeFrame1 = PERIOD_MN1;
      TimeFrame1String = "MN1";

   } else {

      timeFrame1 = 0;

   }
   
   timeFrame2 = Period();
   
   if (timeFrame2 == PERIOD_M1) {
   
      TimeFrame2String = "M1";
   
   } else if (timeFrame2 == PERIOD_M5) {

      TimeFrame2String = "M5";
   
   } else if (timeFrame2 == PERIOD_M15) {

      TimeFrame2String = "M15";
   
   } else if (timeFrame2 == PERIOD_M30) {

      TimeFrame2String = "M30";
   
   } else if (timeFrame2 == PERIOD_H1) {

      TimeFrame2String = "H1";
   
   } else if (timeFrame2 == PERIOD_H4) {

      TimeFrame2String = "H4";
   
   } else if (timeFrame2 == PERIOD_D1) {

      TimeFrame2String = "D1";
   
   } else if (timeFrame2 == PERIOD_W1) {

      TimeFrame2String = "W1";
   
   } else if (timeFrame2 == PERIOD_MN1) {

      TimeFrame2String = "MN1";
   
   }

   if (MA_Type == "SMA") {

      maType = MODE_SMA;

   } else if (MA_Type == "EMA") {

      maType = MODE_EMA;

   } else if (MA_Type == "LWMA") {

      maType = MODE_LWMA;

   } else {

      maType = MODE_SMA;

   }

   if (timeFrame1 < timeFrame2) {

      Alert("The timeframe must be higher than the current");
      deinit();

   }   
   
   return(0); 
  } 

int deinit() 
{ 

   
   ObjectDelete("WLV930");
   ObjectDelete("WLV929");
   ObjectDelete("WLV929B");
   ObjectDelete("WLV931");
   ObjectDelete("WLV932");
   ObjectDelete("WLV934");  
   
ObjectsDeleteAll( win, 21);
ObjectsDeleteAll( win, 22);
ObjectsDeleteAll( win, 23);    
    
}  

//+------------------------------------------------------------------+ 
//| Range                                                            | 
//+------------------------------------------------------------------+ 
int start() 
  { 


 
   int i, idx, counted_bars = IndicatorCounted();
   i = Bars - counted_bars - 1;
   double sum = 0;

   while (i >= 0) {
   
      int timeFrame1Index = iBarShift(0, timeFrame1, Time[i], true);

      // Calculate all values for timeframe1 which is greater than the timeframe1
      // Runs only once every timeframe1 bar
      if (lastBarTime != iTime(NULL, timeFrame1, timeFrame1Index)) {

         lastBarTime = iTime(NULL, timeFrame1, timeFrame1Index);

         // Averages of the selected timeframe
         TimeFrame1CloseAverageMA1 = iMA(NULL, timeFrame1, Period_MA1, 0, maType, PRICE_CLOSE, timeFrame1Index+Calculate_From_Previous_Bar);
         TimeFrame1CloseAverageMA2 = iMA(NULL, timeFrame1, Period_MA2, 0, maType, PRICE_CLOSE, timeFrame1Index+Calculate_From_Previous_Bar);
         TimeFrame1CloseAverageMA3 = iMA(NULL, timeFrame1, Period_MA3, 0, maType, PRICE_CLOSE, timeFrame1Index+Calculate_From_Previous_Bar);
         TimeFrame1CloseAverageMA4 = iMA(NULL, timeFrame1, Period_MA4, 0, maType, PRICE_CLOSE, timeFrame1Index+Calculate_From_Previous_Bar);

         // Highest Highs and Lowest Lows Averages of the selected timeframe
         TimeFrame1HighestHighMA1 = iHigh(NULL, timeFrame1, iHighest(NULL, timeFrame1, MODE_HIGH, Period_MA1, timeFrame1Index+Calculate_From_Previous_Bar));
         TimeFrame1LowestLowMA1 = iLow(NULL, timeFrame1, iLowest(NULL, timeFrame1, MODE_LOW, Period_MA1, timeFrame1Index+Calculate_From_Previous_Bar));

         TimeFrame1HighestHighMA2 = iHigh(NULL, timeFrame1, iHighest(NULL, timeFrame1, MODE_HIGH, Period_MA2, timeFrame1Index+Calculate_From_Previous_Bar));
         TimeFrame1LowestLowMA2 = iLow(NULL, timeFrame1, iLowest(NULL, timeFrame1, MODE_LOW, Period_MA2, timeFrame1Index+Calculate_From_Previous_Bar));

         TimeFrame1HighestHighMA3 = iHigh(NULL, timeFrame1, iHighest(NULL, timeFrame1, MODE_HIGH, Period_MA3, timeFrame1Index+Calculate_From_Previous_Bar));
         TimeFrame1LowestLowMA3 = iLow(NULL, timeFrame1, iLowest(NULL, timeFrame1, MODE_LOW, Period_MA3, timeFrame1Index+Calculate_From_Previous_Bar));

         TimeFrame1HighestHighMA4 = iHigh(NULL, timeFrame1, iHighest(NULL, timeFrame1, MODE_HIGH, Period_MA4, timeFrame1Index+Calculate_From_Previous_Bar));
         TimeFrame1LowestLowMA4 = iLow(NULL, timeFrame1, iLowest(NULL, timeFrame1, MODE_LOW, Period_MA4, timeFrame1Index+Calculate_From_Previous_Bar));

         // HH-LL averages of the selected timeframe
         TimeFrame1HHLLAverageMA1 = TimeFrame1HighestHighMA1 - TimeFrame1LowestLowMA1;
         TimeFrame1HHLLAverageMA2 = TimeFrame1HighestHighMA2 - TimeFrame1LowestLowMA2;
         TimeFrame1HHLLAverageMA3 = TimeFrame1HighestHighMA3 - TimeFrame1LowestLowMA3;
         TimeFrame1HHLLAverageMA4 = TimeFrame1HighestHighMA4 - TimeFrame1LowestLowMA4;
         
         if (Dynamic_BuySell_Price == false) {

            // Highest Highs and Lowest Lows Averages of the currently displayed timeframe
            TimeFrame2HighestHighMA1 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA1, i+Calculate_From_Previous_Bar)];
            TimeFrame2LowestLowMA1 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA1, i+Calculate_From_Previous_Bar)];

            TimeFrame2HighestHighMA2 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA2, i+Calculate_From_Previous_Bar)];
            TimeFrame2LowestLowMA2 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA2, i+Calculate_From_Previous_Bar)];

            TimeFrame2HighestHighMA3 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA3, i+Calculate_From_Previous_Bar)];
            TimeFrame2LowestLowMA3 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA3, i+Calculate_From_Previous_Bar)];

            TimeFrame2HighestHighMA4 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA4, i+Calculate_From_Previous_Bar)];
            TimeFrame2LowestLowMA4 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA4, i+Calculate_From_Previous_Bar)];

         }

      }

      lastBarClose = iClose(NULL, timeFrame1,timeFrame1Index+1);

      if (Dynamic_BuySell_Price == true) {

         // Highest Highs and Lowest Lows Averages of the currently displayed timeframe
         TimeFrame2HighestHighMA1 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA1, i+Calculate_From_Previous_Bar)];
         TimeFrame2LowestLowMA1 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA1, i+Calculate_From_Previous_Bar)];

         TimeFrame2HighestHighMA2 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA2, i+Calculate_From_Previous_Bar)];
         TimeFrame2LowestLowMA2 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA2, i+Calculate_From_Previous_Bar)];

         TimeFrame2HighestHighMA3 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA3, i+Calculate_From_Previous_Bar)];
         TimeFrame2LowestLowMA3 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA3, i+Calculate_From_Previous_Bar)];

         TimeFrame2HighestHighMA4 = High[iHighest(NULL, 0, MODE_HIGH, Period_MA4, i+Calculate_From_Previous_Bar)];
         TimeFrame2LowestLowMA4 = Low[iLowest(NULL, 0, MODE_LOW, Period_MA4, i+Calculate_From_Previous_Bar)];

      }

      // HH-LL averages of the currently displayed timeframe
      TimeFrame2HHLLAverageMA1 = TimeFrame2HighestHighMA1 - TimeFrame2LowestLowMA1;
      TimeFrame2HHLLAverageMA2 = TimeFrame2HighestHighMA2 - TimeFrame2LowestLowMA2;
      TimeFrame2HHLLAverageMA3 = TimeFrame2HighestHighMA3 - TimeFrame2LowestLowMA3;
      TimeFrame2HHLLAverageMA4 = TimeFrame2HighestHighMA4 - TimeFrame2LowestLowMA4;
         
      // Averages of the currently displayed timeframe
      TimeFrame2CloseAverageMA1 = iMA(NULL, 0, Period_MA1, 0, maType, PRICE_CLOSE, i+Calculate_From_Previous_Bar);
      TimeFrame2CloseAverageMA2 = iMA(NULL, 0, Period_MA2, 0, maType, PRICE_CLOSE, i+Calculate_From_Previous_Bar);
      TimeFrame2CloseAverageMA3 = iMA(NULL, 0, Period_MA3, 0, maType, PRICE_CLOSE, i+Calculate_From_Previous_Bar);
      TimeFrame2CloseAverageMA4 = iMA(NULL, 0, Period_MA4, 0, maType, PRICE_CLOSE, i+Calculate_From_Previous_Bar);
      
      if (Symbol() == "GBPUSD") {

         TimeFrame1Level[i] = (TimeFrame1CloseAverageMA1 + TimeFrame1CloseAverageMA2 + TimeFrame1CloseAverageMA3 + TimeFrame1CloseAverageMA4) / 4;
         TimeFrame2Level[i] = (TimeFrame2CloseAverageMA1 + TimeFrame2CloseAverageMA2 + TimeFrame2CloseAverageMA3 + TimeFrame2CloseAverageMA4) / 4;
         
         TimeFrame1HighestHighAverage = (TimeFrame1HighestHighMA1 + TimeFrame1HighestHighMA2 + TimeFrame1HighestHighMA3 + TimeFrame1HighestHighMA4) / 4;
         TimeFrame1LowestLowAverage = (TimeFrame1LowestLowMA1 + TimeFrame1LowestLowMA2 + TimeFrame1LowestLowMA3 + TimeFrame1LowestLowMA4) / 4;
         
         TimeFrame2HighestHighAverage = (TimeFrame2HighestHighMA1 + TimeFrame2HighestHighMA2 + TimeFrame2HighestHighMA3 + TimeFrame2HighestHighMA4) / 4;
         TimeFrame2LowestLowAverage = (TimeFrame2LowestLowMA1 + TimeFrame2LowestLowMA2 + TimeFrame2LowestLowMA3 + TimeFrame2LowestLowMA4) / 4;
         
         InfoDisplay = "*********** " + TimeFrame1String + " Levels ***********\n" + MA_Type + " Period(" + Period_MA1 + ")=" + TimeFrame1CloseAverageMA1 +
                      "\n" + MA_Type + " Period(" + Period_MA2 + ")=" + TimeFrame1CloseAverageMA2 +
                      "\n" + MA_Type + " Period(" + Period_MA3 + ")=" + TimeFrame1CloseAverageMA3 +
                      "\n" + MA_Type + " Period(" + Period_MA4 + ")=" + TimeFrame1CloseAverageMA4 +
                      "\nWaterLevel=" + TimeFrame1Level[i] +
                      "\n*********** " + TimeFrame2String + " Levels ***********\n" + MA_Type + " Period(" + Period_MA1 + ")=" + TimeFrame2CloseAverageMA1 +
                      "\n" + MA_Type + " Period(" + Period_MA2 + ")=" + TimeFrame2CloseAverageMA2 +
                      "\n" + MA_Type + " Period(" + Period_MA3 + ")=" + TimeFrame2CloseAverageMA3 +
                      "\n" + MA_Type + " Period(" + Period_MA4 + ")=" + TimeFrame2CloseAverageMA4 +
                      "\nWaterLevel=" + TimeFrame2Level[i];
				  
      } else {
      
         TimeFrame1Level[i] = (TimeFrame1CloseAverageMA1 + TimeFrame1CloseAverageMA2 + TimeFrame1CloseAverageMA3) / 3;
         TimeFrame2Level[i] = (TimeFrame2CloseAverageMA1 + TimeFrame2CloseAverageMA2 + TimeFrame2CloseAverageMA3) / 3;
         
         TimeFrame1HighestHighAverage = (TimeFrame1HighestHighMA1 + TimeFrame1HighestHighMA2 + TimeFrame1HighestHighMA3) / 3;
         TimeFrame1LowestLowAverage = (TimeFrame1LowestLowMA1 + TimeFrame1LowestLowMA2 + TimeFrame1LowestLowMA3) / 3;
         
         TimeFrame2HighestHighAverage = (TimeFrame2HighestHighMA1 + TimeFrame2HighestHighMA2 + TimeFrame2HighestHighMA3) / 3;
         TimeFrame2LowestLowAverage = (TimeFrame2LowestLowMA1 + TimeFrame2LowestLowMA2 + TimeFrame2LowestLowMA3) / 3;
         
         InfoDisplay = "*********** " + TimeFrame1String + " Levels ***********\n" + MA_Type + " Period(" + Period_MA1 + ")=" + TimeFrame1CloseAverageMA1 +
                      "\n" + MA_Type + " Period(" + Period_MA2 + ")=" + TimeFrame1CloseAverageMA2 +
                      "\n" + MA_Type + " Period(" + Period_MA3 + ")=" + TimeFrame1CloseAverageMA3 +
                      "\nWaterLevel=" + TimeFrame1Level[i] +
                      "\n*********** " + TimeFrame2String + " Levels ***********\n" + MA_Type + " Period(" + Period_MA1 + ")=" + TimeFrame2CloseAverageMA1 +
                      "\n" + MA_Type + " Period(" + Period_MA2 + ")=" + TimeFrame2CloseAverageMA2 +
                      "\n" + MA_Type + " Period(" + Period_MA3 + ")=" + TimeFrame2CloseAverageMA3 +
                      "\nWaterLevel=" + TimeFrame2Level[i];
     
      }
 
      TimeFrame1HHLLAverages = ((TimeFrame1HHLLAverageMA1 + TimeFrame1HHLLAverageMA2 + TimeFrame1HHLLAverageMA3 + TimeFrame1HHLLAverageMA4) / 4) / 4;
      TimeFrame2HHLLAverages = ((TimeFrame2HHLLAverageMA1 + TimeFrame2HHLLAverageMA2 + TimeFrame2HHLLAverageMA3 + TimeFrame2HHLLAverageMA4) / 4) / 4;
     

      
 
      


      SellPrice[i] = lastBarClose + (TimeFrame1HHLLAverages - TimeFrame2HHLLAverages);
      BuyPrice[i] = lastBarClose - (TimeFrame1HHLLAverages - TimeFrame2HHLLAverages);
      
      if (Show_MAs) {

         TimeFrame2AverageMA1[i] = TimeFrame2CloseAverageMA1;
         TimeFrame2AverageMA2[i] = TimeFrame2CloseAverageMA2;
         TimeFrame2AverageMA3[i] = TimeFrame2CloseAverageMA3;
         TimeFrame2AverageMA4[i] = TimeFrame2CloseAverageMA4;
         
      }

      TimeFrame2AverageMA1[i] = (SellPrice[i] + BuyPrice[i]) / 2;


      i--;

   }


Comment( "1 TimeFrame1Level[0] = ",  DoubleToStr( TimeFrame1Level[0] , Digits) ) ;    


/*
ObjectsDeleteAll( win, 21);
ObjectsDeleteAll( win, 22);
ObjectsDeleteAll( win, 23); 
*/

    MaxRange = 0 ; 
    MinRange = 999999 ; 

   double HighVal,LowVal; 
   int limit; 


   AboveAvg = 0 ; 
   BelowAvg = 0 ; 
   AboveCur = 0 ; 
   BelowCur  = 0 ;
  
   limit = MaxBars + 1;  

//---- RANGE counted in the 1-st buffer 


		double buf_tmp = 0 ;
		int z = 0 ;


  
   

   
     zRange = HighVal - LowVal ; // range         
 
   for( i=1; i<limit; i++) 
   { 
 
     if( Close[0] > TimeFrame2Level[0] ) {AboveAvg = AboveAvg + 1  ; } // time frame user
     if( Close[0] < TimeFrame2Level[0] ) {BelowAvg = BelowAvg + 1  ; }     

     if( Close[0] > TimeFrame1Level[0] ) {AboveCur = AboveCur + 1  ; } // time frame chart
     if( Close[0] < TimeFrame1Level[0] ) {BelowCur = BelowCur + 1  ; }     
                 
   } 
  

   AvgRange = buf_tmp / MaxBars /Point ; // average range 
  
   
// xRetPct =  ( 100 ) * ( zRange / AvgRange )  ;  
   


string tPeriod = " "+TimeFrameToString( Chart_Period ) ;

if ( zRange > AvgRange ) { color RangeColor = ThresholdColor ; } else { RangeColor = ColorRange   ; }

   ObjectCreate("WLV930", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("WLV930"," Water("+MaxBars+")", 20, "Arial Bold", ColorHeading);
   ObjectSet("WLV930", OBJPROP_CORNER, 0);
   ObjectSet("WLV930", OBJPROP_XDISTANCE, 760+price.x.offset);
   ObjectSet("WLV930", OBJPROP_YDISTANCE, 160+price.y.offset);

string  RAN929 = DoubleToStr( AboveAvg ,0) + " / " + DoubleToStr( BelowAvg ,0) ;    // top left

   ObjectCreate("WLV929", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("WLV929",RAN929, 15, "Arial Bold", ColorMinMax  );
   ObjectSet("WLV929", OBJPROP_CORNER, 0);
   ObjectSet("WLV929", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("WLV929", OBJPROP_YDISTANCE, 197+price.y.offset);

string  RAN929b = DoubleToStr( AboveCur ,0) + " / " + DoubleToStr( BelowCur ,0) ; 
 
  
   ObjectCreate("WLV929b", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("WLV929b", RAN929b , 15, "Arial Bold", ColorABCur );
   ObjectSet("WLV929b", OBJPROP_CORNER, 0);
   ObjectSet("WLV929b", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("WLV929b", OBJPROP_YDISTANCE, 260+price.y.offset);                 
                   
                   
string  RAN931 = DoubleToStr(zRange,0)+tPeriod + " " + DoubleToStr(xRetPct,0) + "%" ;
                   
   ObjectCreate("WLV931", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("WLV931", RAN931 , 25, "Arial Bold", RangeColor );
   ObjectSet("WLV931", OBJPROP_CORNER, 0);
   ObjectSet("WLV931", OBJPROP_XDISTANCE, 765+price.x.offset); // 765
   ObjectSet("WLV931", OBJPROP_YDISTANCE, 220+price.y.offset); 
           

   ObjectCreate("WLV932", OBJ_LABEL, win, 0, 0);   // 
   ObjectSetText("WLV932",DoubleToStr( TimeFrame2Level[0] , Digits ), 15, "Arial Bold", ColorAvg); // RANGEBuffer2[0] buf0[0]
   ObjectSet("WLV932", OBJPROP_CORNER, 0);
   ObjectSet("WLV932", OBJPROP_XDISTANCE, 860+price.x.offset);
   ObjectSet("WLV932", OBJPROP_YDISTANCE, 197+price.y.offset);
                 
string  RAN934 = DoubleToStr( AboveAvg ,0) + " / " + DoubleToStr( BelowAvg ,0) ;                
           
   ObjectCreate("WLV934", OBJ_LABEL, win, 0, 0);
   ObjectSetText("WLV934", RAN934 , 15, "Arial Bold",  ColorABAvg);
   ObjectSet("WLV934", OBJPROP_CORNER, 0);
   ObjectSet("WLV934", OBJPROP_XDISTANCE, 850+price.x.offset);
   ObjectSet("WLV934", OBJPROP_YDISTANCE, 260+price.y.offset);    
    

   WindowRedraw();    
 
//} 

   return(0); 
} 

//+------------------------------------------------------------------+

 
string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN1";
   }
   return(tfs);
}
 
//+------------------------------------------------------------------+