#property copyright "x"
#property link      "x"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1

#property indicator_maximum 1.0
#property indicator_minimum 0.9

//--- plot Buffer
#property indicator_label1  "Buffer0"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrOrchid
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

//--- input parameters
input int      barsLimit=0;

bool     recalculateBars=true;


//--- indicator buffers
double         Buffer0[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Buffer0);
   
   recalculateBars=true;
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

   int i;

   for(i=barsToCalculate();i>=0;i--)
   {
      double priceHigh = iHigh(Symbol(), Period(), i);
      double priceLow = iLow(Symbol(), Period(), i);
      double lowHigh;
      
      if(priceHigh != 0) 
      { 
         lowHigh = priceLow / priceHigh;
         Buffer0[i] = MathPow(lowHigh, 20);
      }
      else
      {
         Buffer0[i] = 0;
      }
      

   }

   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


int barsToCalculate()
{
   int limit;
   if(recalculateBars==true) 
   {
      if(barsLimit==0) { limit=Bars-20; }
      else { limit=barsLimit; }
      recalculateBars=false;
   }
   else limit=0;
   return(limit);
}


