//+------------------------------------------------------------------+
//|                                                    ExitIndic.mq4 |
//|                                   Copyright © 2010, Kenoby |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Kenoby"
#property link      ""
#property indicator_separate_window // Indic. is drawn in a sep. window
#property indicator_buffers 1 // Amount of buffers
#property indicator_color1 Red // Line color
#property indicator_minimum -10
#property indicator_maximum 10
extern int RSI_period = 4;
extern int Bollinger_period = 20;

double Buf_0[]; // Indicator array opening
//--------------------------------------------------------------- 2 --
int init() // Special init() function
{
SetIndexBuffer(0,Buf_0); // Assigning the array to the buffer
SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style


// NIVEAUX
SetLevelValue (0, 5); 
SetLevelValue(1,-5);
return; // Exit from spec.init() function
}
//--------------------------------------------------------------- 3 --
int start() // Special start() function
{
IndicatorShortName("Exit Indicator");
int i, // Bar index
Counted_bars; // Amount of calculated bars 
int period;




Counted_bars=IndicatorCounted(); // Amount of calculated bars 
i=Bars-Counted_bars-1; // Index of the first uncounted


while(i>=0) // Cycle for the uncounted bars
{
Buf_0[i]=0; // 0 value of the buffer on bar i
if(iRSI(NULL,0,RSI_period,PRICE_CLOSE,i) > 70 && High[i] >= iBands(NULL,0,Bollinger_period,2,0,PRICE_CLOSE,MODE_UPPER,i))
Buf_0[i] = 5;
if(iRSI(NULL,0,RSI_period,PRICE_CLOSE,i) < 30 && Low[i] <= iBands(NULL,0,Bollinger_period,2,0,PRICE_CLOSE,MODE_LOWER,i))
Buf_0[i] = -5;
if(Buf_0[i] == 5 && Buf_0[i+1] == 5)
Buf_0[i] = 0;
if(Buf_0[i] == -5 && Buf_0[i+1] == -5)
Buf_0[i] = 0;
i--; // Index calculation for the next bar
}
return; // Exit from spec.start() function
}

/* IDEES A TESTER

Ajouter MFI:  && iMFI(NULL,0,20,i) > 60
              && iMFI(NULL,0,20,i) < 40  */