RSI_mtf





//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100

#property indicator_level1 30
#property indicator_level2 70
#property indicator_levelcolor DarkSlateGray


#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int TimeFrame=0;
extern int RSIperiod=14;
extern int applied_price=0;
extern int MaxBarsToCount = 2500;

//---- buffers
double RSIBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 
   IndicatorBuffers(1);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSIBuffer);
//---- name for DataWindow and indicator subwindow label

   switch(TimeFrame)
     {
      case 1: string TimeFrameStr="M1";  break;
      case 5     :   TimeFrameStr="M5";  break;
      case 15    :   TimeFrameStr="M15"; break;
      case 30    :   TimeFrameStr="M30"; break;
      case 60    :   TimeFrameStr="H1";  break;
      case 240   :   TimeFrameStr="H4";  break;
      case 1440  :   TimeFrameStr="D1";  break;
      case 10080 :   TimeFrameStr="W1";  break;
      case 43200 :   TimeFrameStr="MN1"; break;
      default :    TimeFrameStr  ="TF0";
     }
  
   short_name="RSI ("+RSIperiod+") ["+TimeFrameStr+"] ";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
  
//----
   if (TimeFrame<Period()) TimeFrame=Period();
//----
   SetIndexDrawBegin(0,RSIperiod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
 {
   datetime TimeArray[];
   int    i,shift,limit,y=0,counted_bars=IndicatorCounted();
    
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
limit = Bars-counted_bars;
limit = MathMax (limit,TimeFrame/Period());
limit=  MathMin(limit,MaxBarsToCount);

   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++; 
   
   RSIBuffer[i]=iRSI(NULL,TimeFrame,RSIperiod,applied_price,y) ; 
 
   }
//----
   return(0);
 }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Relative strength index


Custom Indicators Used:

Order Management characteristics:

Other Features: