#property copyright   "2005-2015, MetaQuotes Software Corp."
#property link        "http://www.inlojv.com"
#property description "INLOJV_long-short"
#property indicator_chart_window
#property indicator_buffers 8


double BMain[];
double BMain1[];
double BMain2[];


double madn[];
double maup[];


double ma1[];
double ma2[];


double cci[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   SetIndexBuffer(0,cci);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(0,DRAW_NONE);
   
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, BMain);
   SetIndexStyle(1,DRAW_NONE);
   
   SetIndexBuffer(2,BMain1);
   SetIndexStyle(2,DRAW_NONE);
   
   SetIndexBuffer(3,BMain2);
   SetIndexStyle(3,DRAW_NONE);
   
   SetIndexBuffer(4,madn);
   SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,3,Red);
   SetIndexArrow(4,110);
   
   SetIndexBuffer(5,maup);
   SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID,3,Lime);
   SetIndexArrow(5,110);

   SetIndexBuffer(6,ma1);
   SetIndexStyle(6,DRAW_NONE);
   
   SetIndexBuffer(7,ma2);
   SetIndexStyle(7,DRAW_NONE);
   return(0);
  }
  
  

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int limit;
   int counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;  
  
  string b="CCI FOR BOLL";
   IndicatorShortName(b);
   

//-----------------------------CCI------------------------------------
   for(int i = limit; i >= 0; i--)
     {   
      cci[i] = iCCI(NULL, 0, 14, PRICE_TYPICAL, i);
    }
   
   for(i = limit; i >= 0; i--)
     {  
      ma1[i]=iMA(NULL,0,3,0,1,PRICE_TYPICAL,i);
      ma2[i]=iMA(NULL,0,1,0,1,PRICE_TYPICAL,i);
      }
//--------------------------Bollinger---------------------------------
   for( i = limit; i >= 0; i--)
     {   
       madn[i]=EMPTY_VALUE;
       maup[i]=EMPTY_VALUE;
     
     BMain[i] = iBands(NULL,0,8,2,0,PRICE_CLOSE,MODE_MAIN,i);
     BMain1[i] = iBands(NULL,0,8,2,0,PRICE_CLOSE,MODE_LOWER,i);
     BMain2[i] = iBands(NULL,0,8,2,0,PRICE_CLOSE,MODE_UPPER,i);
     
     if(Close[i]<Close[i+1] && High[i]<High[i+1] && High[i+1]>BMain2[i] && cci[i]>50 && ma2[i]<ma1[i])
     madn[i]=High[i];

     if(Close[i]>Close[i+1] && Low[i]>Low[i+1] && Low[i+1]<BMain1[i] && cci[i]<-50  && ma2[i]>ma1[i])
     maup[i]=Low[i];

    }


   return(0);
  }
//+------------------------------------------------------------------+