ytg_Def_RSI_v1

Author: Yuriy Tokman
Indicators Used
Relative strength indexMoving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
ytg_Def_RSI_v1
//+------------------------------------------------------------------+
//|                                                  ytg_Def_RSI.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_separate_window

#property  indicator_buffers 2
#property  indicator_color1  Green
#property indicator_level1 0

extern int RSI_1_Period  = 14;//ïåðèîä ïåðâîãî èíäèêàòîðà ÐÑÈ
extern int RSI_2_Period  = 28;//ïåðèîä âòîðîãî èíäèêàòîðà ÐÑÈ
extern int applied_price = 0;//èñïîëüçóåìàÿ öåíà  0-6
extern int ma_period     = 14;//ïåðèîä ñãëàæèâàíèÿ
extern int ma_method     = 0;//ìåòîä ñãëàæèâàíèÿ  0-3

double   buf[];
double   MA_buf[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0, buf);
   
   SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(1,MA_buf);   
   
   IndicatorShortName("ytg_Def_RSI");
   Comment("yuriytokman@gmail.com");   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   double RSI_1,RSI_2;
   
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit--;   

   for(int i=limit; i>=0; i--)
   {
     RSI_1 = iRSI(NULL,0,RSI_1_Period,applied_price,i);
     RSI_2 = iRSI(NULL,0,RSI_2_Period,applied_price,i);

     MA_buf[i] = (RSI_1-RSI_2);
   }
   for(i=limit; i>=0; i--)
   {
     buf[i] = iMAOnArray(MA_buf,0,ma_period,0,ma_method,i);
   }   
   
   
//----
   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 ---