//+------------------------------------------------------------------+
//|                                                   rsi mirror.mq4 |
//|                                                           by cja |
//+------------------------------------------------------------------+
 
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_levelcolor Silver
#property indicator_levelstyle 2
#property indicator_level1 50
//---- input parameters

extern int RSIPeriod = 13; 
extern int RSIPrice  = 0;

//---- indicator buffers
double RSIBuffer1[];
double RSIBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexDrawBegin(0,RSIPeriod);
   SetIndexBuffer(0,RSIBuffer1);
   SetIndexStyle(0,DRAW_LINE);
   
   SetIndexDrawBegin(1,RSIPeriod);
   SetIndexBuffer(1,RSIBuffer2);
   SetIndexStyle(1,DRAW_LINE);
   
   SetIndexLabel(0,"RSI "+RSIPeriod+"");
   SetIndexLabel(1,"RSI "+RSIPeriod+"");
   
   IndicatorDigits(2);
  
   IndicatorShortName("rsi mirror [ "+RSIPeriod+" ]");
   
  
 //---- initialization done
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit(){ return(0);}
//+------------------------------------------------------------------+
//|  RSI                                                             |
//+------------------------------------------------------------------+
int start()
  {
    int i,limit;
   int counted_bars=IndicatorCounted();
   if (counted_bars>0) counted_bars--;
            limit=MathMin(Bars-counted_bars,Bars-1);
  
//---- main loop
     for(i=limit; i>=0; i--)
     {
     
      RSIBuffer1[i]=iRSI(NULL,0,RSIPeriod,RSIPrice,i);
      RSIBuffer2[i]=100-iRSI(NULL,0,RSIPeriod,RSIPrice,i);
  }
   return(0);
  }
//+------------------------------------------------------------------+

