RSI_MTF1





//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                               by Hartono Setiono |
//+------------------------------------------------------------------+
#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_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int RSIPeriod=3;
extern int RSITimeFrame=1440;
extern int applied_price=0;
//---- 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(RSITimeFrame)
   {
      case 1 : short_name="Period_M1"; break;
      case 5 : short_name="Period_M5"; break;
      case 15 : short_name="Period_M15"; break;
      case 30 : short_name="Period_M30"; break;
      case 60 : short_name="Period_H1"; break;
      case 240 : short_name="Period_H4"; break;
      case 1440 : short_name="Period_D1"; break;
      case 10080 : short_name="Period_W1"; break;
      case 43200 : short_name="Period_MN1"; break;
      default : {short_name="Current Timeframe"; RSITimeFrame=0;}
   }
   short_name="RSI_MTF("+short_name+", "+RSIPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,RSIPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,x,counted_bars=IndicatorCounted();
   double rel,negative,positive;
//----
   if(RSITimeFrame==0) RSITimeFrame = Period();
   if(RSITimeFrame==Period()) x=0; else x=1;
   if(Bars<=RSIPeriod) return(0);
   if(Period()<RSIPeriod) return(0);
   
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=RSIPeriod;i++) RSIBuffer[Bars-i]=0.0;
//----
   i=Bars-RSIPeriod-1;
   if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
   while(i>=0)
   {
     RSIBuffer[i]=iRSI(NULL,RSITimeFrame,RSIPeriod,applied_price,MathFloor(i*Period()/RSITimeFrame)+x);
     i--;
   }
//----
   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: