Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
MARSICD
//+------------------------------------------------------------------+
//| MARSICD.mq4 |
//| John Q. Aimsson |
//| aimsson@gmail.com |
//+------------------------------------------------------------------+
#property copyright "John Q. Aimsson"
#property link "aimsson@gmail.com"
#property indicator_separate_window
#property indicator_minimum -100
#property indicator_maximum 100
#property indicator_level1 70
#property indicator_level2 30
#property indicator_level3 -30
#property indicator_level4 -70
#property indicator_level5 50
#property indicator_level6 -50
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Maroon
#property indicator_color3 DarkGray
#property indicator_color4 MediumSeaGreen
#property indicator_color5 Red
#property indicator_color6 Salmon
//---- input parameters
extern int ARSI_PERIOD=14;
extern int RRSI_PERIOD=14;
extern int AMA_PERIOD=5;
extern int RMA_PERIOD=5;
extern int sMAD_PERIOD=21;
//---- buffers
double ARSI_BUF[];
double RRSI_BUF[];
double AMA_BUF[];
double RMA_BUF[];
double Delta[];
double sMAD[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(6);
SetIndexBuffer(0,ARSI_BUF);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(1,RRSI_BUF);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2,Delta);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(3,AMA_BUF);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(4,RMA_BUF);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(5,sMAD);
IndicatorShortName("MARSICD ("+ARSI_PERIOD+","+RRSI_PERIOD+","+AMA_PERIOD+","+RMA_PERIOD+","+sMAD_PERIOD+")");
//----
SetIndexDrawBegin(0,ARSI_PERIOD);
SetIndexDrawBegin(1,RRSI_PERIOD);
SetIndexDrawBegin(3,ARSI_PERIOD+AMA_PERIOD);
SetIndexDrawBegin(4,RRSI_PERIOD+RMA_PERIOD);
SetIndexDrawBegin(5,sMAD_PERIOD);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=ARSI_PERIOD) return(0);
if(Bars<=RRSI_PERIOD) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=ARSI_PERIOD;i++) ARSI_BUF[Bars-i]=0.0;
for(i=1;i<=RRSI_PERIOD;i++) RRSI_BUF[Bars-i]=0.0;
}
//----
i=Bars-ARSI_PERIOD-1;
if(counted_bars>=ARSI_PERIOD) i=Bars-counted_bars-1;
while(i>=0)
{
ARSI_BUF[i]=iRSI(NULL,0,ARSI_PERIOD,6,i);
RRSI_BUF[i]=100.0-iRSI(NULL,0,RRSI_PERIOD,6,i);
Delta[i] = ARSI_BUF[i]-RRSI_BUF[i];
i--;
}
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
//---- signal line is simple movimg average
for(i=0; i<limit; i++)
{
AMA_BUF[i]=iMAOnArray(ARSI_BUF,Bars,AMA_PERIOD,0,MODE_LWMA,i);
RMA_BUF[i]=iMAOnArray(RRSI_BUF,Bars,RMA_PERIOD,0,MODE_LWMA,i);
Delta[i]=AMA_BUF[i]-RMA_BUF[i];
sMAD[i]=iMAOnArray(Delta,Bars,sMAD_PERIOD,0,MODE_LWMA,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
---