#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 OrangeRed
#property indicator_color2 YellowGreen
#property indicator_color3 OrangeRed
#property indicator_color4 YellowGreen
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

extern datetime startdate = D'26.06.2015';
//extern int NbBars = 240;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

int init()
  {

   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer3); 
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer4); 
   
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(2,ExtMapBuffer1); 
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(3,ExtMapBuffer2); 

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
      int NbBars = iBarShift(NULL,0,startdate);
    
      double wr=(High[Highest(NULL,0,MODE_HIGH,NbBars+1,0)]-Low[Lowest(NULL,0,MODE_LOW,NbBars+1,0)])/Point;

      for(int i=0;i<Bars;i++){
         ExtMapBuffer1[i]=EMPTY_VALUE;
         ExtMapBuffer2[i]=EMPTY_VALUE;
         ExtMapBuffer3[i]=EMPTY_VALUE;
         ExtMapBuffer4[i]=EMPTY_VALUE;      
      }
      
      
      for(i=0;i<=NbBars;i++){
         ExtMapBuffer1[i]=1/Open[i];
         ExtMapBuffer2[i]=1/Close[i]; 
         ExtMapBuffer3[i]=1/High[i];
         ExtMapBuffer4[i]=1/Low[i];       
      }
      
      
      double ho=High[Highest(NULL,0,MODE_HIGH,NbBars-0+1,0)];
      double lo=Low[Lowest(NULL,0,MODE_LOW,NbBars-0+1,0)];
      double hn=ExtMapBuffer4[ArrayMaximum(ExtMapBuffer4,NbBars-0+1,0)];
      double ln=ExtMapBuffer3[ArrayMinimum(ExtMapBuffer3,NbBars-0+1,0)];
         
      double RR=ho-lo;
      double NR=hn-ln;
      double KK=RR/NR;
      
      for(i=0;i<=NbBars;i++){
         
         double hh=lo+KK*(ExtMapBuffer1[i]-ln);
         double ll=lo+KK*(ExtMapBuffer2[i]-ln);
         
         ExtMapBuffer1[i]=hh; 
         ExtMapBuffer2[i]=ll; 
         if(Close[i]>Open[i]){ 
            hh=lo+KK*(ExtMapBuffer3[i]-ln);
            ll=lo+KK*(ExtMapBuffer4[i]-ln);   
            ExtMapBuffer4[i]=hh;
            ExtMapBuffer3[i]=ll;         
         }
         else{ 
            ExtMapBuffer3[i]=lo+KK*(ExtMapBuffer3[i]-ln);
            ExtMapBuffer4[i]=lo+KK*(ExtMapBuffer4[i]-ln);  
         }
      }
        
      
          

   return(0);
  }
//+------------------------------------------------------------------+