//+------------------------------------------------------------------+
//|                                    Kase indicator oscillator.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "copyleft mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  LimeGreen
#property indicator_color2  Red

extern int KIOPeriod=10;

//
//
//
//
//

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   for (int i=0; i<indicator_buffers; i++) SetIndexStyle(i,DRAW_LINE);
   IndicatorBuffers(4);
   SetIndexBuffer(0,buffer1); SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(1,buffer2); SetIndexStyle(1,DRAW_SECTION);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);
   IndicatorShortName("Kase indicator ("+KIOPeriod+")");
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
           limit=MathMin(limit,Bars-KIOPeriod-1);

   //
   //
   //
   //
   //
     
   for(i=limit; i>=0; i--)
   {
      buffer1[i] = EMPTY_VALUE;
      buffer2[i] = EMPTY_VALUE;
      buffer3[i] = buffer3[i+1];
      buffer4[i] = buffer4[i+1];
      
      //
      //
      //
      //
      //
      
      if (iATR(NULL,0,KIOPeriod,i)>0)
         {
            buffer3[i] = (High[i+KIOPeriod]/Low[i]);
            buffer4[i] = (High[i]/Low[i+KIOPeriod]);
         }
      if (buffer3[i]>buffer4[i]) buffer2[i] = buffer4[i]-buffer3[i];
      if (buffer3[i]<buffer4[i]) buffer1[i] = buffer4[i]-buffer3[i];
   }
   return(0);
}