Author: Copyright � 2004, MetaQuotes Software Corp.
RSI_mtf
Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
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);
 }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---