RSI_C





//+------------------------------------------------------------------+
//|                                                        RSI_C.mq4 |
//|                                                                * |
//|                                                                * |
//+------------------------------------------------------------------+
#property copyright "Integer"
#property link      "for-good-letters@yandex.ru"

#property indicator_separate_window
#property indicator_maximum 100
#property indicator_minimum 0
#property indicator_buffers 3
#property indicator_color1 Khaki
#property indicator_color2 DeepSkyBlue
#property indicator_color3 Red
//---- input parameters
extern int RSIPeriod =  14;   // Ïåðèîä RSI
extern int RSIPrice  =  0;    // Öåíà RSI: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int RSILevel  =  70;   // Âåðõíèé óðîâåíü RSI, íèæíèé ðàâåí 100-RSILevel
      
//---- buffers
double rsi[];
double up[];
double lo[];
int LoLevel;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,rsi);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,up);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,lo);
   
   LoLevel=100-RSILevel;
   
   SetLevelValue(0,RSILevel);
   SetLevelValue(1,LoLevel);
   
   SetIndexLabel(0,"RSI");
   SetIndexLabel(1,"");   
   SetIndexLabel(2,"");     
   
   SetIndexDrawBegin(0,RSIPeriod+1);
   SetIndexDrawBegin(1,RSIPeriod+1);
   SetIndexDrawBegin(2,RSIPeriod+1);   
   
   IndicatorShortName("RSI");
   
   IndicatorDigits(2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
         int limit=Bars-IndicatorCounted();

            for(int i=limit-1;i>=0;i--){
               up[i]=EMPTY_VALUE;
               lo[i]=EMPTY_VALUE;
               up[i+1]=EMPTY_VALUE;
               lo[i+1]=EMPTY_VALUE;               
               rsi[i]=iRSI(NULL,0,RSIPeriod,RSIPrice,i);
               
               
                  if(rsi[i]>=RSILevel){
                     up[i]=rsi[i];
                     up[i+1]=rsi[i+1];
                  }
                  else{
                     if(rsi[i+1]>=RSILevel){
                        up[i]=rsi[i];
                        up[i+1]=rsi[i+1];
                     }
                  }   
                  if(rsi[i+1]>=RSILevel){
                     up[i+1]=rsi[i+1];
                     up[i+2]=rsi[i+2];
                  }
                  else{
                     if(rsi[i+2]>=RSILevel){
                        up[i+1]=rsi[i+1];
                        up[i+2]=rsi[i+2];
                     }
                  }    
               
               
               
               
               
                  if(rsi[i]<=LoLevel){
                     lo[i]=rsi[i];
                     lo[i+1]=rsi[i+1];
                  }
                  else{
                     if(rsi[i+1]<=LoLevel){
                        lo[i]=rsi[i];
                        lo[i+1]=rsi[i+1];
                     }
                  }   
                  if(rsi[i+1]<=LoLevel){
                     lo[i+1]=rsi[i+1];
                     lo[i+2]=rsi[i+2];
                  }
                  else{
                     if(rsi[i+2]<=LoLevel){
                        lo[i+1]=rsi[i+1];
                        lo[i+2]=rsi[i+2];
                     }
                  }                  
               
               
               
            }
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Relative strength index


Custom Indicators Used:

Order Management characteristics:

Other Features: