Navigation´╝ÜHome > Content >

MARSICD_1.01.mq4

Time: 2018-11-11 | Download file:MARSICD_1.01.mq4

//+------------------------------------------------------------------+
//|                                                      MARSICD.mq4 |
//|                                                  John Q. Aimsson |
//|                                                [email protected] |
//+------------------------------------------------------------------+

#property copyright "John Q. Aimsson"
#property link      "[email protected]"
#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 counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);
  
   for(int i=limit; i>=0; i--) 
     {
      ARSI_BUF[i]=iRSI(NULL,0,ARSI_PERIOD,6,i);
      RRSI_BUF[i]=100.0-iRSI(NULL,0,RRSI_PERIOD,6,i);
     }
   for(i=limit; i>=0; 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];
     }
   for(i=limit; i>=0; i--) 
      sMAD[i]=iMAOnArray(Delta,Bars,sMAD_PERIOD,0,MODE_LWMA,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend