Indicators Used
Miscellaneous
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 Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---