Author: DragoTrade
S-RoC
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
S-RoC
//+------------------------------------------------------------------+
//|                                                        S-RoC.mq4 |
//|                                    Copyright (C) 2009 DragoTrade |
//|                        Licensed under GNU General Public License |
//+------------------------------------------------------------------+
#property copyright "DragoTrade" 

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int MA_Period=13;
extern int ROC_Period=21;
//---- buffers
double b[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,b);
   IndicatorShortName("S-RoC("+MA_Period+", "+ROC_Period+")");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i=Bars-(ROC_Period+MA_Period)-1;
   double t,curr,prev;
   while(i>=0)
   {
      curr=iMA(NULL,0,MA_Period,0,MODE_EMA,PRICE_CLOSE,i);
      prev=iMA(NULL,0,MA_Period,0,MODE_EMA,PRICE_CLOSE,i+ROC_Period);
      if(prev!=0)
      {
         t=(curr-prev)/prev;
      }
      b[i]=t;
      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 ---